aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/config.txt5
-rw-r--r--Documentation/git-clone.txt15
-rw-r--r--Documentation/git-diff.txt4
-rw-r--r--Documentation/git-merge-file.txt92
-rw-r--r--Documentation/git-show-branch.txt10
-rw-r--r--Documentation/git-svnimport.txt13
-rw-r--r--Documentation/git.txt3
-rw-r--r--Documentation/technical/racy-git.txt38
-rwxr-xr-xGIT-VERSION-GEN2
-rw-r--r--Makefile8
-rw-r--r--archive-tar.c1
-rw-r--r--archive-zip.c1
-rw-r--r--blob.c1
-rw-r--r--builtin-add.c7
-rw-r--r--builtin-apply.c1
-rw-r--r--builtin-archive.c1
-rw-r--r--builtin-blame.c48
-rw-r--r--builtin-branch.c90
-rw-r--r--builtin-for-each-ref.c1
-rw-r--r--builtin-grep.c3
-rw-r--r--builtin-init-db.c7
-rw-r--r--builtin-log.c2
-rw-r--r--builtin-ls-files.c2
-rw-r--r--builtin-mailinfo.c9
-rw-r--r--builtin-mailsplit.c7
-rw-r--r--builtin-mv.c2
-rw-r--r--builtin-name-rev.c1
-rw-r--r--builtin-pack-objects.c2
-rw-r--r--builtin-repo-config.c19
-rw-r--r--builtin-rev-list.c6
-rw-r--r--builtin-runstatus.c2
-rw-r--r--builtin-shortlog.c1
-rw-r--r--builtin-show-branch.c37
-rw-r--r--builtin-show-ref.c99
-rw-r--r--builtin-stripspace.c3
-rw-r--r--builtin-tar-tree.c1
-rw-r--r--builtin-unpack-objects.c2
-rw-r--r--builtin-upload-archive.c3
-rw-r--r--cache.h6
-rw-r--r--color.c5
-rw-r--r--commit.c10
-rw-r--r--compat/inet_ntop.c2
-rw-r--r--compat/mmap.c4
-rw-r--r--compat/setenv.c3
-rw-r--r--compat/strlcpy.c2
-rw-r--r--compat/unsetenv.c3
-rw-r--r--config.c80
-rw-r--r--configure.ac4
-rw-r--r--connect.c6
-rw-r--r--contrib/vim/syntax/gitcommit.vim4
-rw-r--r--convert-objects.c4
-rw-r--r--daemon.c16
-rw-r--r--date.c3
-rw-r--r--diff-delta.c5
-rw-r--r--diff.c5
-rw-r--r--diffcore-order.c1
-rw-r--r--diffcore-pickaxe.c2
-rw-r--r--dir.c3
-rw-r--r--entry.c2
-rw-r--r--exec_cmd.c4
-rw-r--r--fetch-pack.c1
-rw-r--r--fetch.c3
-rw-r--r--fsck-objects.c3
-rwxr-xr-xgit-clone.sh61
-rw-r--r--git-compat-util.h25
-rwxr-xr-xgit-cvsserver.perl2
-rwxr-xr-xgit-fetch.sh14
-rwxr-xr-xgit-ls-remote.sh2
-rwxr-xr-xgit-merge.sh26
-rwxr-xr-xgit-parse-remote.sh21
-rwxr-xr-xgit-pull.sh4
-rwxr-xr-xgit-rerere.perl2
-rw-r--r--git.c14
-rwxr-xr-xgitweb/gitweb.perl227
-rw-r--r--grep.c1
-rw-r--r--help.c3
-rw-r--r--ident.c18
-rw-r--r--imap-send.c7
-rw-r--r--index-pack.c24
-rw-r--r--interpolate.c2
-rw-r--r--lockfile.c1
-rw-r--r--log-tree.c26
-rw-r--r--merge-base.c1
-rw-r--r--merge-index.c4
-rw-r--r--merge-recursive.c9
-rw-r--r--patch-delta.c13
-rw-r--r--path-list.c1
-rw-r--r--path.c1
-rw-r--r--pkt-line.c2
-rw-r--r--read-cache.c6
-rw-r--r--receive-pack.c3
-rw-r--r--refs.c14
-rw-r--r--revision.c10
-rw-r--r--revision.h2
-rw-r--r--rsh.c6
-rw-r--r--run-command.c1
-rw-r--r--sha1_file.c4
-rw-r--r--ssh-upload.c2
-rw-r--r--strbuf.c4
-rwxr-xr-xt/t0000-basic.sh9
-rwxr-xr-xt/t1300-repo-config.sh48
-rwxr-xr-xt/t3200-branch.sh6
-rwxr-xr-xt/t5510-fetch.sh7
-rwxr-xr-xt/test-lib.sh3
-rw-r--r--templates/remotes--1
-rw-r--r--test-date.c3
-rw-r--r--test-delta.c8
-rw-r--r--tree.c1
-rw-r--r--unpack-trees.c2
-rw-r--r--upload-pack.c3
-rw-r--r--var.c3
-rw-r--r--wt-status.c4
112 files changed, 933 insertions, 458 deletions
diff --git a/Documentation/config.txt b/Documentation/config.txt
index ceac54b02..22482d6a9 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -31,6 +31,11 @@ Example
external = "/usr/local/bin/gnu-diff -u"
renames = true
+ [branch "devel"]
+ remote = origin
+ merge = refs/heads/devel
+
+
Variables
~~~~~~~~~
diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt
index 985043fac..874934a33 100644
--- a/Documentation/git-clone.txt
+++ b/Documentation/git-clone.txt
@@ -11,8 +11,7 @@ SYNOPSIS
[verse]
'git-clone' [--template=<template_directory>] [-l [-s]] [-q] [-n] [--bare]
[-o <name>] [-u <upload-pack>] [--reference <repository>]
- [--use-separate-remote | --no-separate-remote] <repository>
- [<directory>]
+ <repository> [<directory>]
DESCRIPTION
-----------
@@ -99,18 +98,6 @@ OPTIONS
if unset the templates are taken from the installation
defined default, typically `/usr/share/git-core/templates`.
---use-separate-remote::
- Save remotes heads under `$GIT_DIR/remotes/origin/` instead
- of `$GIT_DIR/refs/heads/`. Only the local master branch is
- saved in the latter. This is the default.
-
---no-separate-remote::
- Save remotes heads in the same namespace as the local
- heads, `$GIT_DIR/refs/heads/'. In regular repositories,
- this is a legacy setup git-clone created by default in
- older Git versions, and will be removed before the next
- major release.
-
<repository>::
The (possibly remote) repository to clone from. It can
be any URL git-fetch supports.
diff --git a/Documentation/git-diff.txt b/Documentation/git-diff.txt
index 10fdf88dc..8977877b2 100644
--- a/Documentation/git-diff.txt
+++ b/Documentation/git-diff.txt
@@ -8,7 +8,7 @@ git-diff - Show changes between commits, commit and working tree, etc
SYNOPSIS
--------
-'git-diff' [ --diff-options ] <tree-ish>{0,2} [--] [<path>...]
+'git-diff' [ --diff-options ] <commit>{0,2} [--] [<path>...]
DESCRIPTION
-----------
@@ -26,7 +26,7 @@ tree and the index file, or the index file and the working tree.
'git-diff' [--options] --cached [<commit>] [--] [<path>...]::
This form is to view the changes you staged for the next
- commit relative to the named <tree-ish>. Typically you
+ commit relative to the named <commit>. Typically you
would want comparison with the latest commit, so if you
do not give <commit>, it defaults to HEAD.
diff --git a/Documentation/git-merge-file.txt b/Documentation/git-merge-file.txt
new file mode 100644
index 000000000..29d3faa55
--- /dev/null
+++ b/Documentation/git-merge-file.txt
@@ -0,0 +1,92 @@
+git-merge-file(1)
+=================
+
+NAME
+----
+git-merge-file - three-way file merge
+
+
+SYNOPSIS
+--------
+[verse]
+'git-merge-file' [-L <current-name> [-L <base-name> [-L <other-name>]]]
+ [-p|--stdout] [-q|--quiet] <current-file> <base-file> <other-file>
+
+
+DESCRIPTION
+-----------
+git-file-merge incorporates all changes that lead from the `<base-file>`
+to `<other-file>` into `<current-file>`. The result ordinarily goes into
+`<current-file>`. git-merge-file is useful for combining separate changes
+to an original. Suppose `<base-file>` is the original, and both
+`<current-file>` and `<other-file>` are modifications of `<base-file>`.
+Then git-merge-file combines both changes.
+
+A conflict occurs if both `<current-file>` and `<other-file>` have changes
+in a common segment of lines. If a conflict is found, git-merge-file
+normally outputs a warning and brackets the conflict with <<<<<<< and
+>>>>>>> lines. A typical conflict will look like this:
+
+ <<<<<<< A
+ lines in file A
+ =======
+ lines in file B
+ >>>>>>> B
+
+If there are conflicts, the user should edit the result and delete one of
+the alternatives.
+
+The exit value of this program is negative on error, and the number of
+conflicts otherwise. If the merge was clean, the exit value is 0.
+
+git-merge-file is designed to be a minimal clone of RCS merge, that is, it
+implements all of RCS merge's functionality which is needed by
+gitlink:git[1].
+
+
+OPTIONS
+-------
+
+-L <label>::
+ This option may be given up to three times, and
+ specifies labels to be used in place of the
+ corresponding file names in conflict reports. That is,
+ `git-merge-file -L x -L y -L z a b c` generates output that
+ looks like it came from files x, y and z instead of
+ from files a, b and c.
+
+-p::
+ Send results to standard output instead of overwriting
+ `<current-file>`.
+
+-q::
+ Quiet; do not warn about conflicts.
+
+
+EXAMPLES
+--------
+
+git merge-file README.my README README.upstream::
+
+ combines the changes of README.my and README.upstream since README,
+ tries to merge them and writes the result into README.my.
+
+git merge-file -L a -L b -L c tmp/a123 tmp/b234 tmp/c345::
+
+ merges tmp/a123 and tmp/c345 with the base tmp/b234, but uses labels
+ `a` and `c` instead of `tmp/a123` and `tmp/c345`.
+
+
+Author
+------
+Written by Johannes Schindelin <johannes.schindelin@gmx.de>
+
+
+Documentation
+--------------
+Documentation by Johannes Schindelin and the git-list <git@vger.kernel.org>,
+with parts copied from the original documentation of RCS merge.
+
+GIT
+---
+Part of the gitlink:git[7] suite
diff --git a/Documentation/git-show-branch.txt b/Documentation/git-show-branch.txt
index a2445a48f..948ff10e6 100644
--- a/Documentation/git-show-branch.txt
+++ b/Documentation/git-show-branch.txt
@@ -10,7 +10,7 @@ SYNOPSIS
[verse]
'git-show-branch' [--all] [--heads] [--tags] [--topo-order] [--current]
[--more=<n> | --list | --independent | --merge-base]
- [--no-name | --sha1-name] [<rev> | <glob>]...
+ [--no-name | --sha1-name] [--topics] [<rev> | <glob>]...
DESCRIPTION
-----------
@@ -86,6 +86,14 @@ OPTIONS
of "master"), name them with the unique prefix of their
object names.
+--topics::
+ Shows only commits that are NOT on the first branch given.
+ This helps track topic branches by hiding any commit that
+ is already in the main line of development. When given
+ "git show-branch --topics master topic1 topic2", this
+ will show the revisions given by "git rev-list {caret}master
+ topic1 topic2"
+
Note that --more, --list, --independent and --merge-base options
are mutually exclusive.
diff --git a/Documentation/git-svnimport.txt b/Documentation/git-svnimport.txt
index b1b87c2fc..2c7c7dad5 100644
--- a/Documentation/git-svnimport.txt
+++ b/Documentation/git-svnimport.txt
@@ -15,6 +15,7 @@ SYNOPSIS
[ -b branch_subdir ] [ -T trunk_subdir ] [ -t tag_subdir ]
[ -s start_chg ] [ -m ] [ -r ] [ -M regex ]
[ -I <ignorefile_name> ] [ -A <author_file> ]
+ [ -P <path_from_trunk> ]
<SVN_repository_URL> [ <path> ]
@@ -103,9 +104,17 @@ repository without -A.
-l <max_rev>::
Specify a maximum revision number to pull.
++
+Formerly, this option controlled how many revisions to pull,
+due to SVN memory leaks. (These have been worked around.)
- Formerly, this option controlled how many revisions to pull,
- due to SVN memory leaks. (These have been worked around.)
+-P <path_from_trunk>::
+ Partial import of the SVN tree.
++
+By default, the whole tree on the SVN trunk (/trunk) is imported.
+'-P my/proj' will import starting only from '/trunk/my/proj'.
+This option is useful when you want to import one project from a
+svn repo which hosts multiple projects under the same trunk.
-v::
Verbosity: let 'svnimport' report what it is doing.
diff --git a/Documentation/git.txt b/Documentation/git.txt
index 6382ef0a0..2a9e97dac 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -351,6 +351,9 @@ gitlink:git-init-db[1]::
Creates an empty git object database, or reinitialize an
existing one.
+gitlink:git-merge-file[1]::
+ Runs a threeway merge.
+
gitlink:git-merge-index[1]::
Runs a merge for files needing merging.
diff --git a/Documentation/technical/racy-git.txt b/Documentation/technical/racy-git.txt
index 7597d0414..5030d9f2f 100644
--- a/Documentation/technical/racy-git.txt
+++ b/Documentation/technical/racy-git.txt
@@ -4,7 +4,7 @@ Use of index and Racy git problem
Background
----------
-The index is one of the most important data structure in git.
+The index is one of the most important data structures in git.
It represents a virtual working tree state by recording list of
paths and their object names and serves as a staging area to
write out the next tree object to be committed. The state is
@@ -16,7 +16,7 @@ virtual working tree state in the index and the files in the
working tree. The most obvious case is when the user asks `git
diff` (or its low level implementation, `git diff-files`) or
`git-ls-files --modified`. In addition, git internally checks
-if the files in the working tree is different from what are
+if the files in the working tree are different from what are
recorded in the index to avoid stomping on local changes in them
during patch application, switching branches, and merging.
@@ -24,9 +24,9 @@ In order to speed up this comparison between the files in the
working tree and the index entries, the index entries record the
information obtained from the filesystem via `lstat(2)` system
call when they were last updated. When checking if they differ,
-git first runs `lstat(2)` on the files and compare the result
+git first runs `lstat(2)` on the files and compares the result
with this information (this is what was originally done by the
-`ce_match_stat()` function, which the current code does in
+`ce_match_stat()` function, but the current code does it in
`ce_match_stat_basic()` function). If some of these "cached
stat information" fields do not match, git can tell that the
files are modified without even looking at their contents.
@@ -53,8 +53,9 @@ Racy git
There is one slight problem with the optimization based on the
cached stat information. Consider this sequence:
+ : modify 'foo'
$ git update-index 'foo'
- : modify 'foo' in-place without changing its size
+ : modify 'foo' again, in-place, without changing its size
The first `update-index` computes the object name of the
contents of file `foo` and updates the index entry for `foo`
@@ -62,7 +63,8 @@ along with the `struct stat` information. If the modification
that follows it happens very fast so that the file's `st_mtime`
timestamp does not change, after this sequence, the cached stat
information the index entry records still exactly match what you
-can obtain from the filesystem, but the file `foo` is modified.
+would see in the filesystem, even though the file `foo` is now
+different.
This way, git can incorrectly think files in the working tree
are unmodified even though they actually are. This is called
the "racy git" problem (discovered by Pasky), and the entries
@@ -87,7 +89,7 @@ the stat information from updated paths, `st_mtime` timestamp of
it is usually the same as or newer than any of the paths the
index contains. And no matter how quick the modification that
follows `git update-index foo` finishes, the resulting
-`st_mtime` timestamp on `foo` cannot get the timestamp earlier
+`st_mtime` timestamp on `foo` cannot get a value earlier
than the index file. Therefore, index entries that can be
racily clean are limited to the ones that have the same
timestamp as the index file itself.
@@ -111,7 +113,7 @@ value, and falsely clean entry `foo` would not be caught by the
timestamp comparison check done with the former logic anymore.
The latter makes sure that the cached stat information for `foo`
would never match with the file in the working tree, so later
-checks by `ce_match_stat_basic()` would report the index entry
+checks by `ce_match_stat_basic()` would report that the index entry
does not match the file and git does not have to fall back on more
expensive `ce_modified_check_fs()`.
@@ -155,17 +157,16 @@ of the cached stat information.
Avoiding runtime penalty
------------------------
-In order to avoid the above runtime penalty, the recent "master"
-branch (post 1.4.2) has a code that makes sure the index file
-gets timestamp newer than the youngest files in the index when
+In order to avoid the above runtime penalty, post 1.4.2 git used
+to have a code that made sure the index file
+got timestamp newer than the youngest files in the index when
there are many young files with the same timestamp as the
resulting index file would otherwise would have by waiting
before finishing writing the index file out.
-I suspect that in practice the situation where many paths in the
-index are all racily clean is quite rare. The only code paths
-that can record recent timestamp for large number of paths I
-know of are:
+I suspected that in practice the situation where many paths in the
+index are all racily clean was quite rare. The only code paths
+that can record recent timestamp for large number of paths are:
. Initial `git add .` of a large project.
@@ -188,6 +189,7 @@ youngest file in the working tree. This means that in these
cases there actually will not be any racily clean entry in
the resulting index.
-So in summary I think we should not worry about avoiding the
-runtime penalty and get rid of the "wait before finishing
-writing" code out.
+Based on this discussion, the current code does not use the
+"workaround" to avoid the runtime penalty that does not exist in
+practice anymore. This was done with commit 0fc82cff on Aug 15,
+2006.
diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index 4eac314f3..eca1ff217 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -1,7 +1,7 @@
#!/bin/sh
GVF=GIT-VERSION-FILE
-DEF_VER=v1.4.4.1.GIT
+DEF_VER=v1.4.4.GIT
LF='
'
diff --git a/Makefile b/Makefile
index 05cfe45b1..76511045a 100644
--- a/Makefile
+++ b/Makefile
@@ -82,10 +82,6 @@ all:
# Define NO_ACCURATE_DIFF if your diff program at least sometimes misses
# a missing newline at the end of the file.
#
-# Define COLLISION_CHECK below if you believe that SHA1's
-# 1461501637330902918203684832716283019655932542976 hashes do not give you
-# sufficient guarantee that no collisions between objects will ever happen.
-#
# Define USE_NSEC below if you want git to care about sub-second file mtimes
# and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
# it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
@@ -796,8 +792,8 @@ test: all
test-date$X: test-date.c date.o ctype.o
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) test-date.c date.o ctype.o
-test-delta$X: test-delta.c diff-delta.o patch-delta.o
- $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $^
+test-delta$X: test-delta.o diff-delta.o patch-delta.o $(GITLIBS)
+ $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
test-dump-cache-tree$X: dump-cache-tree.o $(GITLIBS)
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
diff --git a/archive-tar.c b/archive-tar.c
index ff0f6e292..af47fdc95 100644
--- a/archive-tar.c
+++ b/archive-tar.c
@@ -1,7 +1,6 @@
/*
* Copyright (c) 2005, 2006 Rene Scharfe
*/
-#include <time.h>
#include "cache.h"
#include "commit.h"
#include "strbuf.h"
diff --git a/archive-zip.c b/archive-zip.c
index 36e922a1f..f31b8ed82 100644
--- a/archive-zip.c
+++ b/archive-zip.c
@@ -1,7 +1,6 @@
/*
* Copyright (c) 2006 Rene Scharfe
*/
-#include <time.h>
#include "cache.h"
#include "commit.h"
#include "blob.h"
diff --git a/blob.c b/blob.c
index d1af2e62f..9776beac5 100644
--- a/blob.c
+++ b/blob.c
@@ -1,6 +1,5 @@
#include "cache.h"
#include "blob.h"
-#include <stdlib.h>
const char *blob_type = "blob";
diff --git a/builtin-add.c b/builtin-add.c
index b3f920676..f306f82b1 100644
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -3,8 +3,6 @@
*
* Copyright (C) 2006 Linus Torvalds
*/
-#include <fnmatch.h>
-
#include "cache.h"
#include "builtin.h"
#include "dir.h"
@@ -113,6 +111,11 @@ int cmd_add(int argc, const char **argv, const char *prefix)
}
usage(builtin_add_usage);
}
+ if (argc <= i) {
+ fprintf(stderr, "Nothing specified, nothing added.\n");
+ fprintf(stderr, "Maybe you wanted to say 'git add .'?\n");
+ return 0;
+ }
pathspec = get_pathspec(prefix, argv + i);
fill_directory(&dir, pathspec);
diff --git a/builtin-apply.c b/builtin-apply.c
index 436d9e188..1c3583706 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -6,7 +6,6 @@
* This applies patches on top of some (arbitrary) version of the SCM.
*
*/
-#include <fnmatch.h>
#include "cache.h"
#include "cache-tree.h"
#include "quote.h"
diff --git a/builtin-archive.c b/builtin-archive.c
index a8a1f079b..391cf4391 100644
--- a/builtin-archive.c
+++ b/builtin-archive.c
@@ -2,7 +2,6 @@
* Copyright (c) 2006 Franck Bui-Huu
* Copyright (c) 2006 Rene Scharfe
*/
-#include <time.h>
#include "cache.h"
#include "builtin.h"
#include "archive.h"
diff --git a/builtin-blame.c b/builtin-blame.c
index dc3ffeaff..4a1accf13 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -15,14 +15,12 @@
#include "revision.h"
#include "xdiff-interface.h"
-#include <time.h>
-#include <sys/time.h>
-#include <regex.h>
-
static char blame_usage[] =
"git-blame [-c] [-l] [-t] [-f] [-n] [-p] [-L n,m] [-S <revs-file>] [-M] [-C] [-C] [commit] [--] file\n"
" -c, --compatibility Use the same output mode as git-annotate (Default: off)\n"
+" -b Show blank SHA-1 for boundary commits (Default: off)\n"
" -l, --long Show long commit SHA1 (Default: off)\n"
+" --root Do not treat root commits as boundaries (Default: off)\n"
" -t, --time Show raw timestamp (Default: off)\n"
" -f, --show-name Show original filename (Default: auto)\n"
" -n, --show-number Show original linenumber (Default: off)\n"
@@ -36,6 +34,8 @@ static int longest_author;
static int max_orig_digits;
static int max_digits;
static int max_score_digits;
+static int show_root;
+static int blank_boundary;
#ifndef DEBUG
#define DEBUG 0
@@ -1090,6 +1090,14 @@ static void assign_blame(struct scoreboard *sb, struct rev_info *revs, int opt)
if (!(commit->object.flags & UNINTERESTING) &&
!(revs->max_age != -1 && commit->date < revs->max_age))
pass_blame(sb, suspect, opt);
+ else {
+ commit->object.flags |= UNINTERESTING;
+ if (commit->object.parsed)
+ mark_parents_uninteresting(commit);
+ }
+ /* treat root commit as boundary */
+ if (!commit->parents && !show_root)
+ commit->object.flags |= UNINTERESTING;
/* Take responsibility for the remaining entries */
for (ent = sb->ent; ent; ent = ent->next)
@@ -1273,6 +1281,8 @@ static void emit_porcelain(struct scoreboard *sb, struct blame_entry *ent)
printf("committer-tz %s\n", ci.committer_tz);
printf("filename %s\n", suspect->path);
printf("summary %s\n", ci.summary);
+ if (suspect->commit->object.flags & UNINTERESTING)
+ printf("boundary\n");
}
else if (suspect->commit->object.flags & MORE_THAN_ONE_PATH)
printf("filename %s\n", suspect->path);
@@ -1308,8 +1318,18 @@ static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt)
cp = nth_line(sb, ent->lno);
for (cnt = 0; cnt < ent->num_lines; cnt++) {
char ch;
+ int length = (opt & OUTPUT_LONG_OBJECT_NAME) ? 40 : 8;
+
+ if (suspect->commit->object.flags & UNINTERESTING) {
+ if (!blank_boundary) {
+ length--;
+ putchar('^');
+ }
+ else
+ memset(hex, ' ', length);
+ }
- printf("%.*s", (opt & OUTPUT_LONG_OBJECT_NAME) ? 40 : 8, hex);
+ printf("%.*s", length, hex);
if (opt & OUTPUT_ANNOTATE_COMPAT)
printf("\t(%10s\t%10s\t%d)", ci.author,
format_time(ci.author_time, ci.author_tz,
@@ -1626,6 +1646,19 @@ static void prepare_blame_range(struct scoreboard *sb,
usage(blame_usage);
}
+static int git_blame_config(const char *var, const char *value)
+{
+ if (!strcmp(var, "blame.showroot")) {
+ show_root = git_config_bool(var, value);
+ return 0;
+ }
+ if (!strcmp(var, "blame.blankboundary")) {
+ blank_boundary = git_config_bool(var, value);
+ return 0;
+ }
+ return git_default_config(var, value);
+}
+
int cmd_blame(int argc, const char **argv, const char *prefix)
{
struct rev_info revs;
@@ -1641,6 +1674,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
char type[10];
const char *bottomtop = NULL;
+ git_config(git_blame_config);
save_commit_buffer = 0;
opt = 0;
@@ -1649,6 +1683,10 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
const char *arg = argv[i];
if (*arg != '-')
break;
+ else if (!strcmp("-b", arg))
+ blank_boundary = 1;
+ else if (!strcmp("--root", arg))
+ show_root = 1;
else if (!strcmp("-c", arg))
output_option |= OUTPUT_ANNOTATE_COMPAT;
else if (!strcmp("-t", arg))
diff --git a/builtin-branch.c b/builtin-branch.c
index 560309cb1..903d5cf05 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -5,15 +5,19 @@
* Based on git-branch.sh by Junio C Hamano.
*/
-#include "color.h"
#include "cache.h"
+#include "color.h"
#include "refs.h"
#include "commit.h"
#include "builtin.h"
static const char builtin_branch_usage[] =
- "git-branch (-d | -D) <branchname> | [-l] [-f] <branchname> [<start-point>] | (-m | -M) [<oldbranch>] <newbranch> | [-r | -a] [-v [--abbrev=<length>]]";
+ "git-branch [-r] (-d | -D) <branchname> | [-l] [-f] <branchname> [<start-point>] | (-m | -M) [<oldbranch>] <newbranch> | [-r | -a] [-v [--abbrev=<length>]]";
+#define REF_UNKNOWN_TYPE 0x00
+#define REF_LOCAL_BRANCH 0x01
+#define REF_REMOTE_BRANCH 0x02
+#define REF_TAG 0x04
static const char *head;
static unsigned char head_sha1[20];
@@ -89,12 +93,28 @@ static int in_merge_bases(const unsigned char *sha1,
return ret;
}
-static void delete_branches(int argc, const char **argv, int force)
+static int delete_branches(int argc, const char **argv, int force, int kinds)
{
struct commit *rev, *head_rev = head_rev;
unsigned char sha1[20];
- char *name;
+ char *name = NULL;
+ const char *fmt, *remote;
int i;
+ int ret = 0;
+
+ switch (kinds) {
+ case REF_REMOTE_BRANCH:
+ fmt = "refs/remotes/%s";
+ remote = "remote ";
+ force = 1;
+ break;
+ case REF_LOCAL_BRANCH:
+ fmt = "refs/heads/%s";
+ remote = "";
+ break;
+ default:
+ die("cannot use -a with -d");
+ }
if (!force) {
head_rev = lookup_commit_reference(head_sha1);
@@ -102,16 +122,30 @@ static void delete_branches(int argc, const char **argv, int force)
die("Couldn't look up commit object for HEAD");
}
for (i = 0; i < argc; i++) {
- if (!strcmp(head, argv[i]))
- die("Cannot delete the branch you are currently on.");
+ if (kinds == REF_LOCAL_BRANCH && !strcmp(head, argv[i])) {
+ error("Cannot delete the branch '%s' "
+ "which you are currently on.", argv[i]);
+ ret = 1;
+ continue;
+ }
- name = xstrdup(mkpath("refs/heads/%s", argv[i]));
- if (!resolve_ref(name, sha1, 1, NULL))
- die("Branch '%s' not found.", argv[i]);
+ if (name)
+ free(name);
+
+ name = xstrdup(mkpath(fmt, argv[i]));
+ if (!resolve_ref(name, sha1, 1, NULL)) {
+ error("%sbranch '%s' not found.",
+ remote, argv[i]);
+ ret = 1;
+ continue;
+ }
rev = lookup_commit_reference(sha1);
- if (!rev)
- die("Couldn't look up commit object for '%s'", name);
+ if (!rev) {
+ error("Couldn't look up commit object for '%s'", name);
+ ret = 1;
+ continue;
+ }
/* This checks whether the merge bases of branch and
* HEAD contains branch -- which means that the HEAD
@@ -120,26 +154,28 @@ static void delete_branches(int argc, const char **argv, int force)
if (!force &&
!in_merge_bases(sha1, rev, head_rev)) {
- fprintf(stderr,
- "The branch '%s' is not a strict subset of your current HEAD.\n"
- "If you are sure you want to delete it, run 'git branch -D %s'.\n",
- argv[i], argv[i]);
- exit(1);
+ error("The branch '%s' is not a strict subset of "
+ "your current HEAD.\n"
+ "If you are sure you want to delete it, "
+ "run 'git branch -D %s'.", argv[i], argv[i]);
+ ret = 1;
+ continue;
}
- if (delete_ref(name, sha1))
- printf("Error deleting branch '%s'\n", argv[i]);
- else
- printf("Deleted branch %s.\n", argv[i]);
+ if (delete_ref(name, sha1)) {
+ error("Error deleting %sbranch '%s'", remote,
+ argv[i]);
+ ret = 1;
+ } else
+ printf("Deleted %sbranch %s.\n", remote, argv[i]);
- free(name);
}
-}
-#define REF_UNKNOWN_TYPE 0x00
-#define REF_LOCAL_BRANCH 0x01
-#define REF_REMOTE_BRANCH 0x02
-#define REF_TAG 0x04
+ if (name)
+ free(name);
+
+ return(ret);
+}
struct ref_item {
char *name;
@@ -435,7 +471,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
head += 11;
if (delete)
- delete_branches(argc - i, argv + i, force_delete);
+ return delete_branches(argc - i, argv + i, force_delete, kinds);
else if (i == argc)
print_ref_list(kinds, verbose, abbrev);
else if (rename && (i == argc - 1))
diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c
index 227aa3cd7..af72a12a5 100644
--- a/builtin-for-each-ref.c
+++ b/builtin-for-each-ref.c
@@ -6,7 +6,6 @@
#include "tree.h"
#include "blob.h"
#include "quote.h"
-#include <fnmatch.h>
/* Quoting styles */
#define QUOTE_NONE 0
diff --git a/builtin-grep.c b/builtin-grep.c
index 9873e3d1d..3b1b1cbbf 100644
--- a/builtin-grep.c
+++ b/builtin-grep.c
@@ -10,10 +10,7 @@
#include "tag.h"
#include "tree-walk.h"
#include "builtin.h"
-#include <regex.h>
#include "grep.h"
-#include <fnmatch.h>
-#include <sys/wait.h>
/*
* git grep pathspecs are somewhat different from diff-tree pathspecs;
diff --git a/builtin-init-db.c b/builtin-init-db.c
index 1d7d15e8d..01f366ad0 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -124,8 +124,11 @@ static void copy_templates(const char *git_dir, int len, const char *template_di
int template_len;
DIR *dir;
- if (!template_dir)
- template_dir = DEFAULT_GIT_TEMPLATE_DIR;
+ if (!template_dir) {
+ template_dir = getenv(TEMPLATE_DIR_ENVIRONMENT);
+ if (!template_dir)
+ template_dir = DEFAULT_GIT_TEMPLATE_DIR;
+ }
strcpy(template_path, template_dir);
template_len = strlen(template_path);
if (template_path[template_len-1] != '/') {
diff --git a/builtin-log.c b/builtin-log.c
index 17014f70a..8df3c1394 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -11,8 +11,6 @@
#include "log-tree.h"
#include "builtin.h"
#include "tag.h"
-#include <time.h>
-#include <sys/time.h>
static int default_show_root = 1;
diff --git a/builtin-ls-files.c b/builtin-ls-files.c
index bc79ce40f..21c2a6e2d 100644
--- a/builtin-ls-files.c
+++ b/builtin-ls-files.c
@@ -5,8 +5,6 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
-#include <fnmatch.h>
-
#include "cache.h"
#include "quote.h"
#include "dir.h"
diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
index b8d7dbc0b..e6472293d 100644
--- a/builtin-mailinfo.c
+++ b/builtin-mailinfo.c
@@ -2,15 +2,6 @@
* Another stupid program, this one parsing the headers of an
* email to figure out authorship and subject
*/
-#define _GNU_SOURCE
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#ifndef NO_ICONV
-#include <iconv.h>
-#endif
-#include "git-compat-util.h"
#include "cache.h"
#include "builtin.h"
diff --git a/builtin-mailsplit.c b/builtin-mailsplit.c
index 91a699d34..3bca855aa 100644
--- a/builtin-mailsplit.c
+++ b/builtin-mailsplit.c
@@ -4,13 +4,6 @@
* It just splits a mbox into a list of files: "0001" "0002" ..
* so you can process them further from there.
*/
-#include <unistd.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <string.h>
-#include <stdio.h>
#include "cache.h"
#include "builtin.h"
diff --git a/builtin-mv.c b/builtin-mv.c
index d14a4a7f5..737af350b 100644
--- a/builtin-mv.c
+++ b/builtin-mv.c
@@ -3,8 +3,6 @@
*
* Copyright (C) 2006 Johannes Schindelin
*/
-#include <fnmatch.h>
-
#include "cache.h"
#include "builtin.h"
#include "dir.h"
diff --git a/builtin-name-rev.c b/builtin-name-rev.c
index 618aa314d..b4f15cc38 100644
--- a/builtin-name-rev.c
+++ b/builtin-name-rev.c
@@ -1,4 +1,3 @@
-#include <stdlib.h>
#include "builtin.h"
#include "cache.h"
#include "commit.h"
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index a2dc7d1d9..807be8c3f 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -12,8 +12,6 @@
#include "diff.h"
#include "revision.h"
#include "list-objects.h"
-#include <sys/time.h>
-#include <signal.h>
static const char pack_usage[] = "\
git-pack-objects [{ -q | --progress | --all-progress }] \n\
diff --git a/builtin-repo-config.c b/builtin-repo-config.c
index 64fbdb7b2..90633119d 100644
--- a/builtin-repo-config.c
+++ b/builtin-repo-config.c
@@ -1,9 +1,8 @@
#include "builtin.h"
#include "cache.h"
-#include <regex.h>
static const char git_config_set_usage[] =
-"git-repo-config [ --global ] [ --bool | --int ] [--get | --get-all | --get-regexp | --replace-all | --add | --unset | --unset-all] name [value [value_regex]] | --list";
+"git-repo-config [ --global ] [ --bool | --int ] [--get | --get-all | --get-regexp | --replace-all | --add | --unset | --unset-all] name [value [value_regex]] | --rename-section old_name new_name | --list";
static char *key;
static regex_t *key_regexp;
@@ -67,10 +66,10 @@ static int get_value(const char* key_, const char* regex_)
char *global = NULL, *repo_config = NULL;
const char *local;
- local = getenv("GIT_CONFIG");
+ local = getenv(CONFIG_ENVIRONMENT);
if (!local) {
const char *home = getenv("HOME");
- local = getenv("GIT_CONFIG_LOCAL");
+ local = getenv(CONFIG_LOCAL_ENVIRONMENT);
if (!local)
local = repo_config = xstrdup(git_path("config"));
if (home)
@@ -148,6 +147,18 @@ int cmd_repo_config(int argc, const char **argv, const char *prefix)
} else {
die("$HOME not set");
}
+ } else if (!strcmp(argv[1], "--rename-section")) {
+ int ret;
+ if (argc != 4)
+ usage(git_config_set_usage);
+ ret = git_config_rename_section(argv[2], argv[3]);
+ if (ret < 0)
+ return ret;
+ if (ret == 0) {
+ fprintf(stderr, "No such section!\n");
+ return 1;
+ }
+ return 0;
} else
break;
argc--;
diff --git a/builtin-rev-list.c b/builtin-rev-list.c
index fb7fc9214..1bb3a0668 100644
--- a/builtin-rev-list.c
+++ b/builtin-rev-list.c
@@ -54,6 +54,12 @@ static void show_commit(struct commit *commit)
fputs(header_prefix, stdout);
if (commit->object.flags & BOUNDARY)
putchar('-');
+ else if (revs.left_right) {
+ if (commit->object.flags & SYMMETRIC_LEFT)
+ putchar('<');
+ else
+ putchar('>');
+ }
if (revs.abbrev_commit && revs.abbrev)
fputs(find_unique_abbrev(commit->object.sha1, revs.abbrev),
stdout);
diff --git a/builtin-runstatus.c b/builtin-runstatus.c
index 0b63037dd..4b489b121 100644
--- a/builtin-runstatus.c
+++ b/builtin-runstatus.c
@@ -1,5 +1,5 @@
-#include "wt-status.h"
#include "cache.h"
+#include "wt-status.h"
extern int wt_status_use_color;
diff --git a/builtin-shortlog.c b/builtin-shortlog.c
index 3fc43dd7d..edb40429e 100644
--- a/builtin-shortlog.c
+++ b/builtin-shortlog.c
@@ -4,7 +4,6 @@
#include "diff.h"
#include "path-list.h"
#include "revision.h"
-#include <string.h>
static const char shortlog_usage[] =
"git-shortlog [-n] [-s] [<commit-id>... ]";
diff --git a/builtin-show-branch.c b/builtin-show-branch.c
index fb1a4000d..b9d9781d4 100644
--- a/builtin-show-branch.c
+++ b/builtin-show-branch.c
@@ -1,12 +1,10 @@
-#include <stdlib.h>
-#include <fnmatch.h>
#include "cache.h"
#include "commit.h"
#include "refs.h"
#include "builtin.h"
static const char show_branch_usage[] =
-"git-show-branch [--sparse] [--current] [--all] [--heads] [--tags] [--topo-order] [--more=count | --list | --independent | --merge-base ] [--topics] [<refs>...]";
+"git-show-branch [--sparse] [--current] [--all] [--heads] [--tags] [--topo-order] [--more=count | --list | --independent | --merge-base ] [--topics] [<refs>...] | --reflog[=n] <branch>";
static int default_num;
static int default_alloc;
@@ -17,6 +15,8 @@ static const char **default_arg;
#define REV_SHIFT 2
#define MAX_REVS (FLAG_BITS - REV_SHIFT) /* should not exceed bits_per_int - REV_SHIFT */
+#define DEFAULT_REFLOG 4
+
static struct commit *interesting(struct commit_list *list)
{
while (list) {
@@ -570,6 +570,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
int head_at = -1;
int topics = 0;
int dense = 1;
+ int reflog = 0;
git_config(git_show_branch_config);
@@ -615,6 +616,15 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
dense = 0;
else if (!strcmp(arg, "--date-order"))
lifo = 0;
+ else if (!strcmp(arg, "--reflog")) {
+ reflog = DEFAULT_REFLOG;
+ }
+ else if (!strncmp(arg, "--reflog=", 9)) {
+ char *end;
+ reflog = strtoul(arg + 9, &end, 10);
+ if (*end != '\0')
+ die("unrecognized reflog count '%s'", arg + 9);
+ }
else
usage(show_branch_usage);
ac--; av++;
@@ -622,7 +632,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
ac--; av++;
/* Only one of these is allowed */
- if (1 < independent + merge_base + (extra != 0))
+ if (1 < independent + merge_base + (extra != 0) + (!!reflog))
usage(show_branch_usage);
/* If nothing is specified, show all branches by default */
@@ -631,9 +641,22 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
if (all_heads + all_tags)
snarf_refs(all_heads, all_tags);
- while (0 < ac) {
- append_one_rev(*av);
- ac--; av++;
+ if (reflog) {
+ int reflen;
+ if (!ac)
+ die("--reflog option needs one branch name");
+ reflen = strlen(*av);
+ for (i = 0; i < reflog; i++) {
+ char *name = xmalloc(reflen + 20);
+ sprintf(name, "%s@{%d}", *av, i);
+ append_one_rev(name);
+ }
+ }
+ else {
+ while (0 < ac) {
+ append_one_rev(*av);
+ ac--; av++;
+ }
}
head_p = resolve_ref("HEAD", head_sha1, 1, NULL);
diff --git a/builtin-show-ref.c b/builtin-show-ref.c
index 073979855..853f13f6a 100644
--- a/builtin-show-ref.c
+++ b/builtin-show-ref.c
@@ -2,13 +2,23 @@
#include "refs.h"
#include "object.h"
#include "tag.h"
+#include "path-list.h"
-static const char show_ref_usage[] = "git show-ref [-q|--quiet] [--verify] [-h|--head] [-d|--dereference] [-s|--hash[=<length>]] [--abbrev[=<length>]] [--tags] [--heads] [--] [pattern*]";
+static const char show_ref_usage[] = "git show-ref [-q|--quiet] [--verify] [-h|--head] [-d|--dereference] [-s|--hash[=<length>]] [--abbrev[=<length>]] [--tags] [--heads] [--] [pattern*] < ref-list";
static int deref_tags = 0, show_head = 0, tags_only = 0, heads_only = 0,
found_match = 0, verify = 0, quiet = 0, hash_only = 0, abbrev = 0;
static const char **pattern;
+static void show_one(const char *refname, const unsigned char *sha1)
+{
+ const char *hex = find_unique_abbrev(sha1, abbrev);
+ if (hash_only)
+ printf("%s\n", hex);
+ else
+ printf("%s %s\n", hex, refname);
+}
+
static int show_ref(const char *refname, const unsigned char *sha1, int flag, void *cbdata)
{
struct object *obj;
@@ -57,11 +67,7 @@ match:
if (quiet)
return 0;
- hex = find_unique_abbrev(sha1, abbrev);
- if (hash_only)
- printf("%s\n", hex);
- else
- printf("%s %s\n", hex, refname);
+ show_one(refname, sha1);
if (!deref_tags)
return 0;
@@ -86,6 +92,60 @@ match:
return 0;
}
+static int add_existing(const char *refname, const unsigned char *sha1, int flag, void *cbdata)
+{
+ struct path_list *list = (struct path_list *)cbdata;
+ path_list_insert(refname, list);
+ return 0;
+}
+
+/*
+ * read "^(?:<anything>\s)?<refname>(?:\^\{\})?$" from the standard input,
+ * and
+ * (1) strip "^{}" at the end of line if any;
+ * (2) ignore if match is provided and does not head-match refname;
+ * (3) warn if refname is not a well-formed refname and skip;
+ * (4) ignore if refname is a ref that exists in the local repository;
+ * (5) otherwise output the line.
+ */
+static int exclude_existing(const char *match)
+{
+ static struct path_list existing_refs = { NULL, 0, 0, 0 };
+ char buf[1024];
+ int matchlen = match ? strlen(match) : 0;
+
+ for_each_ref(add_existing, &existing_refs);
+ while (fgets(buf, sizeof(buf), stdin)) {
+ char *ref;
+ int len = strlen(buf);
+
+ if (len > 0 && buf[len - 1] == '\n')
+ buf[--len] = '\0';
+ if (3 <= len && !strcmp(buf + len - 3, "^{}")) {
+ len -= 3;
+ buf[len] = '\0';
+ }
+ for (ref = buf + len; buf < ref; ref--)
+ if (isspace(ref[-1]))
+ break;
+ if (match) {
+ int reflen = buf + len - ref;
+ if (reflen < matchlen)
+ continue;
+ if (strncmp(ref, match, matchlen))
+ continue;
+ }
+ if (check_ref_format(ref)) {
+ fprintf(stderr, "warning: ref '%s' ignored\n", ref);
+ continue;
+ }
+ if (!path_list_has_path(&existing_refs, ref)) {
+ printf("%s\n", buf);
+ }
+ }
+ return 0;
+}
+
int cmd_show_ref(int argc, const char **argv, const char *prefix)
{
int i;
@@ -121,13 +181,13 @@ int cmd_show_ref(int argc, const char **argv, const char *prefix)
if (!strncmp(arg, "--hash=", 7) ||
(!strncmp(arg, "--abbrev", 8) &&
(arg[8] == '=' || arg[8] == '\0'))) {
- if (arg[3] != 'h' && !arg[8])
+ if (arg[2] != 'h' && !arg[8])
/* --abbrev only */
abbrev = DEFAULT_ABBREV;
else {
/* --hash= or --abbrev= */
char *end;
- if (arg[3] == 'h') {
+ if (arg[2] == 'h') {
hash_only = 1;
arg += 7;
}
@@ -153,8 +213,31 @@ int cmd_show_ref(int argc, const char **argv, const char *prefix)
heads_only = 1;
continue;
}
+ if (!strcmp(arg, "--exclude-existing"))
+ return exclude_existing(NULL);
+ if (!strncmp(arg, "--exclude-existing=", 19))
+ return exclude_existing(arg + 19);
usage(show_ref_usage);
}
+
+ if (verify) {
+ unsigned char sha1[20];
+
+ while (*pattern) {
+ if (!strncmp(*pattern, "refs/", 5) &&
+ resolve_ref(*pattern, sha1, 1, NULL)) {
+ if (!quiet)
+ show_one(*pattern, sha1);
+ }
+ else if (!quiet)
+ die("'%s' - not a valid ref", *pattern);
+ else
+ return 1;
+ pattern++;
+ }
+ return 0;
+ }
+
if (show_head)
head_ref(show_ref, NULL);
for_each_ref(show_ref, NULL);
diff --git a/builtin-stripspace.c b/builtin-stripspace.c
index 09cc9108c..f0d4d9e2d 100644
--- a/builtin-stripspace.c
+++ b/builtin-stripspace.c
@@ -1,6 +1,3 @@
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
#include "builtin.h"
/*
diff --git a/builtin-tar-tree.c b/builtin-tar-tree.c
index 4d4cfec87..11e62fc14 100644
--- a/builtin-tar-tree.c
+++ b/builtin-tar-tree.c
@@ -1,7 +1,6 @@
/*
* Copyright (c) 2005, 2006 Rene Scharfe
*/
-#include <time.h>
#include "cache.h"
#include "commit.h"
#include "tar.h"
diff --git a/builtin-unpack-objects.c b/builtin-unpack-objects.c
index e6d757484..d351e0264 100644
--- a/builtin-unpack-objects.c
+++ b/builtin-unpack-objects.c
@@ -8,8 +8,6 @@
#include "tag.h"
#include "tree.h"
-#include <sys/time.h>
-
static int dry_run, quiet, recover, has_errors;
static const char unpack_usage[] = "git-unpack-objects [-n] [-q] [-r] < pack-file";
diff --git a/builtin-upload-archive.c b/builtin-upload-archive.c
index 45c92e163..e4156f8f4 100644
--- a/builtin-upload-archive.c
+++ b/builtin-upload-archive.c
@@ -1,9 +1,6 @@
/*
* Copyright (c) 2006 Franck Bui-Huu
*/
-#include <time.h>
-#include <sys/wait.h>
-#include <sys/poll.h>
#include "cache.h"
#include "builtin.h"
#include "archive.h"
diff --git a/cache.h b/cache.h
index 2d3df98dc..4943056c1 100644
--- a/cache.h
+++ b/cache.h
@@ -122,6 +122,10 @@ extern int cache_errno;
#define DB_ENVIRONMENT "GIT_OBJECT_DIRECTORY"
#define INDEX_ENVIRONMENT "GIT_INDEX_FILE"
#define GRAFT_ENVIRONMENT "GIT_GRAFT_FILE"
+#define TEMPLATE_DIR_ENVIRONMENT "GIT_TEMPLATE_DIR"
+#define CONFIG_ENVIRONMENT "GIT_CONFIG"
+#define CONFIG_LOCAL_ENVIRONMENT "GIT_CONFIG_LOCAL"
+#define EXEC_PATH_ENVIRONMENT "GIT_EXEC_PATH"
extern int is_bare_git_dir(const char *dir);
extern const char *get_git_dir(void);
@@ -309,6 +313,7 @@ void datestamp(char *buf, int bufsize);
unsigned long approxidate(const char *);
extern int setup_ident(void);
+extern void ignore_missing_committer_name();
extern const char *git_author_info(int);
extern const char *git_committer_info(int);
@@ -404,6 +409,7 @@ extern int git_config_int(const char *, const char *);
extern int git_config_bool(const char *, const char *);
extern int git_config_set(const char *, const char *);
extern int git_config_set_multivar(const char *, const char *, const char *, int);
+extern int git_config_rename_section(const char *, const char *);
extern int check_repository_format_version(const char *var, const char *value);
#define MAX_GITNAME (1000)
diff --git a/color.c b/color.c
index d8c8399d5..09d82eec3 100644
--- a/color.c
+++ b/color.c
@@ -1,8 +1,5 @@
-#include "color.h"
#include "cache.h"
-#include "git-compat-util.h"
-
-#include <stdarg.h>
+#include "color.h"
#define COLOR_RESET "\033[m"
diff --git a/commit.c b/commit.c
index a6d543eee..289ef65eb 100644
--- a/commit.c
+++ b/commit.c
@@ -868,11 +868,11 @@ void sort_in_topological_order_fn(struct commit_list ** list, int lifo,
/* merge-rebase stuff */
-/* bits #0..7 in revision.h */
-#define PARENT1 (1u<< 8)
-#define PARENT2 (1u<< 9)
-#define STALE (1u<<10)
-#define RESULT (1u<<11)
+/* bits #0..15 in revision.h */
+#define PARENT1 (1u<<16)
+#define PARENT2 (1u<<17)
+#define STALE (1u<<18)
+#define RESULT (1u<<19)
static struct commit *interesting(struct commit_list *list)
{
diff --git a/compat/inet_ntop.c b/compat/inet_ntop.c
index ec8c1bff5..4d7ab9d97 100644
--- a/compat/inet_ntop.c
+++ b/compat/inet_ntop.c
@@ -93,7 +93,7 @@ inet_ntop6(src, dst, size)
*/
char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp;
struct { int base, len; } best, cur;
- u_int words[NS_IN6ADDRSZ / NS_INT16SZ];
+ unsigned int words[NS_IN6ADDRSZ / NS_INT16SZ];
int i;
/*
diff --git a/compat/mmap.c b/compat/mmap.c
index a4d2e507f..0fd46e793 100644
--- a/compat/mmap.c
+++ b/compat/mmap.c
@@ -1,7 +1,3 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
#include "../git-compat-util.h"
void *gitfakemmap(void *start, size_t length, int prot , int flags, int fd, off_t offset)
diff --git a/compat/setenv.c b/compat/setenv.c
index b7d767859..3a22ea7b7 100644
--- a/compat/setenv.c
+++ b/compat/setenv.c
@@ -1,5 +1,4 @@
-#include <stdlib.h>
-#include <string.h>
+#include "../git-compat-util.h"
int gitsetenv(const char *name, const char *value, int replace)
{
diff --git a/compat/strlcpy.c b/compat/strlcpy.c
index b66856a3a..4024c3603 100644
--- a/compat/strlcpy.c
+++ b/compat/strlcpy.c
@@ -1,4 +1,4 @@
-#include <string.h>
+#include "../git-compat-util.h"
size_t gitstrlcpy(char *dest, const char *src, size_t size)
{
diff --git a/compat/unsetenv.c b/compat/unsetenv.c
index 3a5e4ec04..eb29f5e08 100644
--- a/compat/unsetenv.c
+++ b/compat/unsetenv.c
@@ -1,5 +1,4 @@
-#include <stdlib.h>
-#include <string.h>
+#include "../git-compat-util.h"
void gitunsetenv (const char *name)
{
diff --git a/config.c b/config.c
index 1bdef44a3..1662a4626 100644
--- a/config.c
+++ b/config.c
@@ -6,7 +6,6 @@
*
*/
#include "cache.h"
-#include <regex.h>
#define MAXNAME (256)
@@ -350,10 +349,10 @@ int git_config(config_fn_t fn)
* $GIT_CONFIG_LOCAL will make it process it in addition to the
* global config file, the same way it would the per-repository
* config file otherwise. */
- filename = getenv("GIT_CONFIG");
+ filename = getenv(CONFIG_ENVIRONMENT);
if (!filename) {
home = getenv("HOME");
- filename = getenv("GIT_CONFIG_LOCAL");
+ filename = getenv(CONFIG_LOCAL_ENVIRONMENT);
if (!filename)
filename = repo_config = xstrdup(git_path("config"));
}
@@ -544,9 +543,9 @@ int git_config_set_multivar(const char* key, const char* value,
char* lock_file;
const char* last_dot = strrchr(key, '.');
- config_filename = getenv("GIT_CONFIG");
+ config_filename = getenv(CONFIG_ENVIRONMENT);
if (!config_filename) {
- config_filename = getenv("GIT_CONFIG_LOCAL");
+ config_filename = getenv(CONFIG_LOCAL_ENVIRONMENT);
if (!config_filename)
config_filename = git_path("config");
}
@@ -746,4 +745,75 @@ out_free:
return ret;
}
+int git_config_rename_section(const char *old_name, const char *new_name)
+{
+ int ret = 0;
+ char *config_filename;
+ struct lock_file *lock = xcalloc(sizeof(struct lock_file), 1);
+ int out_fd;
+ char buf[1024];
+
+ config_filename = getenv(CONFIG_ENVIRONMENT);
+ if (!config_filename) {
+ config_filename = getenv(CONFIG_LOCAL_ENVIRONMENT);
+ if (!config_filename)
+ config_filename = git_path("config");
+ }
+ config_filename = xstrdup(config_filename);
+ out_fd = hold_lock_file_for_update(lock, config_filename, 0);
+ if (out_fd < 0) {
+ ret = error("Could not lock config file!");
+ goto out;
+ }
+
+ if (!(config_file = fopen(config_filename, "rb"))) {
+ ret = error("Could not open config file!");
+ goto out;
+ }
+
+ while (fgets(buf, sizeof(buf), config_file)) {
+ int i;
+ for (i = 0; buf[i] && isspace(buf[i]); i++)
+ ; /* do nothing */
+ if (buf[i] == '[') {
+ /* it's a section */
+ int j = 0, dot = 0;
+ for (i++; buf[i] && buf[i] != ']'; i++) {
+ if (!dot && isspace(buf[i])) {
+ dot = 1;
+ if (old_name[j++] != '.')
+ break;
+ for (i++; isspace(buf[i]); i++)
+ ; /* do nothing */
+ if (buf[i] != '"')
+ break;
+ continue;
+ }
+ if (buf[i] == '\\' && dot)
+ i++;
+ else if (buf[i] == '"' && dot) {
+ for (i++; isspace(buf[i]); i++)
+ ; /* do_nothing */
+ break;
+ }
+ if (buf[i] != old_name[j++])
+ break;
+ }
+ if (buf[i] == ']') {
+ /* old_name matches */
+ ret++;
+ store.baselen = strlen(new_name);
+ store_write_section(out_fd, new_name);
+ continue;
+ }
+ }
+ write(out_fd, buf, strlen(buf));
+ }
+ fclose(config_file);
+ if (close(out_fd) || commit_lock_file(lock) < 0)
+ ret = error("Cannot commit config file!");
+ out:
+ free(config_filename);
+ return ret;
+}
diff --git a/configure.ac b/configure.ac
index 34e34789b..e153d5382 100644
--- a/configure.ac
+++ b/configure.ac
@@ -316,10 +316,6 @@ GIT_PARSE_WITH(iconv))
## --enable-FEATURE[=ARG] and --disable-FEATURE
#
-# Define COLLISION_CHECK below if you believe that SHA1's
-# 1461501637330902918203684832716283019655932542976 hashes do not give you
-# sufficient guarantee that no collisions between objects will ever happen.
-#
# Define USE_NSEC below if you want git to care about sub-second file mtimes
# and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
# it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
diff --git a/connect.c b/connect.c
index f7edba82c..66daa11a5 100644
--- a/connect.c
+++ b/connect.c
@@ -3,12 +3,6 @@
#include "pkt-line.h"
#include "quote.h"
#include "refs.h"
-#include <sys/wait.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <signal.h>
static char *server_capabilities;
diff --git a/contrib/vim/syntax/gitcommit.vim b/contrib/vim/syntax/gitcommit.vim
index a9de09fa2..d911efbb4 100644
--- a/contrib/vim/syntax/gitcommit.vim
+++ b/contrib/vim/syntax/gitcommit.vim
@@ -1,7 +1,7 @@
syn region gitLine start=/^#/ end=/$/
-syn region gitCommit start=/^# Updated but not checked in:$/ end=/^#$/ contains=gitHead,gitCommitFile
+syn region gitCommit start=/^# Added but not yet committed:$/ end=/^#$/ contains=gitHead,gitCommitFile
syn region gitHead contained start=/^# (.*)/ end=/^#$/
-syn region gitChanged start=/^# Changed but not updated:/ end=/^#$/ contains=gitHead,gitChangedFile
+syn region gitChanged start=/^# Changed but not added:/ end=/^#$/ contains=gitHead,gitChangedFile
syn region gitUntracked start=/^# Untracked files:/ end=/^#$/ contains=gitHead,gitUntrackedFile
syn match gitCommitFile contained /^#\t.*/hs=s+2
diff --git a/convert-objects.c b/convert-objects.c
index 881258311..a63013298 100644
--- a/convert-objects.c
+++ b/convert-objects.c
@@ -1,7 +1,3 @@
-#define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */
-#define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
-#define _GNU_SOURCE
-#include <time.h>
#include "cache.h"
#include "blob.h"
#include "commit.h"
diff --git a/daemon.c b/daemon.c
index e66bb802d..b129b83e4 100644
--- a/daemon.c
+++ b/daemon.c
@@ -1,20 +1,10 @@
-#include <signal.h>
-#include <sys/wait.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <sys/poll.h>
-#include <netdb.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <syslog.h>
-#include <pwd.h>
-#include <grp.h>
-#include <limits.h>
-#include "pkt-line.h"
#include "cache.h"
+#include "pkt-line.h"
#include "exec_cmd.h"
#include "interpolate.h"
+#include <syslog.h>
+
#ifndef HOST_NAME_MAX
#define HOST_NAME_MAX 256
#endif
diff --git a/date.c b/date.c
index 182592273..7acb8cbd9 100644
--- a/date.c
+++ b/date.c
@@ -4,9 +4,6 @@
* Copyright (C) Linus Torvalds, 2005
*/
-#include <time.h>
-#include <sys/time.h>
-
#include "cache.h"
static time_t my_mktime(struct tm *tm)
diff --git a/diff-delta.c b/diff-delta.c
index fa16d06c8..9f998d0a7 100644
--- a/diff-delta.c
+++ b/diff-delta.c
@@ -18,11 +18,8 @@
* licensing gets turned into GPLv2 within this project.
*/
-#include <stdlib.h>
-#include <string.h>
-#include "delta.h"
-
#include "git-compat-util.h"
+#include "delta.h"
/* maximum hash entry list for the same hash bucket */
#define HASH_LIMIT 64
diff --git a/diff.c b/diff.c
index 99744354a..91f956b23 100644
--- a/diff.c
+++ b/diff.c
@@ -1,9 +1,6 @@
/*
* Copyright (C) 2005 Junio C Hamano
*/
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <signal.h>
#include "cache.h"
#include "quote.h"
#include "diff.h"
@@ -1223,7 +1220,7 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int
* objects however would tend to be slower as they need
* to be individually opened and inflated.
*/
- if (FAST_WORKING_DIRECTORY && !want_file && has_sha1_pack(sha1, NULL))
+ if (!FAST_WORKING_DIRECTORY && !want_file && has_sha1_pack(sha1, NULL))
return 0;
len = strlen(name);
diff --git a/diffcore-order.c b/diffcore-order.c
index aef6da604..7ad094618 100644
--- a/diffcore-order.c
+++ b/diffcore-order.c
@@ -4,7 +4,6 @@
#include "cache.h"
#include "diff.h"
#include "diffcore.h"
-#include <fnmatch.h>
static char **order;
static int order_cnt;
diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c
index cfcce315b..de44adabf 100644
--- a/diffcore-pickaxe.c
+++ b/diffcore-pickaxe.c
@@ -5,8 +5,6 @@
#include "diff.h"
#include "diffcore.h"
-#include <regex.h>
-
static unsigned int contains(struct diff_filespec *one,
const char *needle, unsigned long len,
regex_t *regexp)
diff --git a/dir.c b/dir.c
index e6a61ee91..16401d801 100644
--- a/dir.c
+++ b/dir.c
@@ -5,9 +5,6 @@
* Copyright (C) Linus Torvalds, 2005-2006
* Junio Hamano, 2005-2006
*/
-#include <dirent.h>
-#include <fnmatch.h>
-
#include "cache.h"
#include "dir.h"
diff --git a/entry.c b/entry.c
index b2ea0efa8..88df71394 100644
--- a/entry.c
+++ b/entry.c
@@ -1,5 +1,3 @@
-#include <sys/types.h>
-#include <dirent.h>
#include "cache.h"
#include "blob.h"
diff --git a/exec_cmd.c b/exec_cmd.c
index 5d6a1247b..3996bce33 100644
--- a/exec_cmd.c
+++ b/exec_cmd.c
@@ -21,7 +21,7 @@ const char *git_exec_path(void)
if (current_exec_path)
return current_exec_path;
- env = getenv("GIT_EXEC_PATH");
+ env = getenv(EXEC_PATH_ENVIRONMENT);
if (env && *env) {
return env;
}
@@ -35,7 +35,7 @@ int execv_git_cmd(const char **argv)
char git_command[PATH_MAX + 1];
int i;
const char *paths[] = { current_exec_path,
- getenv("GIT_EXEC_PATH"),
+ getenv(EXEC_PATH_ENVIRONMENT),
builtin_exec_path };
for (i = 0; i < ARRAY_SIZE(paths); ++i) {
diff --git a/fetch-pack.c b/fetch-pack.c
index 743eab7ef..92322cf4d 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -5,7 +5,6 @@
#include "tag.h"
#include "exec_cmd.h"
#include "sideband.h"
-#include <sys/wait.h>
static int keep_pack;
static int quiet;
diff --git a/fetch.c b/fetch.c
index 663b4b2f4..f69be82f1 100644
--- a/fetch.c
+++ b/fetch.c
@@ -1,6 +1,5 @@
-#include "fetch.h"
-
#include "cache.h"
+#include "fetch.h"
#include "commit.h"
#include "tree.h"
#include "tree-walk.h"
diff --git a/fsck-objects.c b/fsck-objects.c
index 46b628cb9..409aea02b 100644
--- a/fsck-objects.c
+++ b/fsck-objects.c
@@ -1,6 +1,3 @@
-#include <sys/types.h>
-#include <dirent.h>
-
#include "cache.h"
#include "commit.h"
#include "tree.h"
diff --git a/git-clone.sh b/git-clone.sh
index 1f5d07a05..490f3e48d 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -14,7 +14,7 @@ die() {
}
usage() {
- die "Usage: $0 [--template=<template_directory>] [--no-separate-remote] [--reference <reference-repo>] [--bare] [-l [-s]] [-q] [-u <upload-pack>] [--origin <name>] [-n] <repo> [<dir>]"
+ die "Usage: $0 [--template=<template_directory>] [--reference <reference-repo>] [--bare] [-l [-s]] [-q] [-u <upload-pack>] [--origin <name>] [-n] <repo> [<dir>]"
}
get_repo_base() {
@@ -137,11 +137,9 @@ while
*,--template=*)
template="$1" ;;
*,-q|*,--quiet) quiet=-q ;;
- *,--use-separate-remote)
- # default
- use_separate_remote=t ;;
+ *,--use-separate-remote) ;;
*,--no-separate-remote)
- use_separate_remote= ;;
+ die "clones are always made with separate-remote layout" ;;
1,--reference) usage ;;
*,--reference)
shift; reference="$1" ;;
@@ -327,12 +325,8 @@ cd "$D" || exit
if test -z "$bare" && test -f "$GIT_DIR/REMOTE_HEAD"
then
- # Figure out which remote branch HEAD points at.
- case "$use_separate_remote" in
- '') remote_top=refs/heads ;;
- *) remote_top="refs/remotes/$origin" ;;
- esac
-
+ # a non-bare repository is always in separate-remote layout
+ remote_top="refs/remotes/$origin"
head_sha1=`cat "$GIT_DIR/REMOTE_HEAD"`
case "$head_sha1" in
'ref: refs/'*)
@@ -366,41 +360,26 @@ then
)
)
- # Write out remotes/$origin file, and update our "$head_points_at".
+ # Write out remote.$origin config, and update our "$head_points_at".
case "$head_points_at" in
?*)
- mkdir -p "$GIT_DIR/remotes" &&
+ # Local default branch
git-symbolic-ref HEAD "refs/heads/$head_points_at" &&
- case "$use_separate_remote" in
- t) origin_track="$remote_top/$head_points_at"
- git-update-ref HEAD "$head_sha1" ;;
- *) origin_track="$remote_top/$origin"
- git-update-ref "refs/heads/$origin" "$head_sha1" ;;
- esac &&
+
+ # Tracking branch for the primary branch at the remote.
+ origin_track="$remote_top/$head_points_at" &&
+ git-update-ref HEAD "$head_sha1" &&
+
+ # Upstream URL
git-repo-config remote."$origin".url "$repo" &&
+
+ # Set up the mappings to track the remote branches.
git-repo-config remote."$origin".fetch \
- "refs/heads/$head_points_at:$origin_track" &&
- (cd "$GIT_DIR/$remote_top" && find . -type f -print) |
- while read dotslref
- do
- name=`expr "$dotslref" : './\(.*\)'`
- if test "z$head_points_at" = "z$name"
- then
- continue
- fi
- if test "$use_separate_remote" = '' &&
- test "z$origin" = "z$name"
- then
- continue
- fi
- git-repo-config remote."$origin".fetch "refs/heads/${name}:$remote_top/${name}" '^$'
- done &&
- case "$use_separate_remote" in
- t)
- rm -f "refs/remotes/$origin/HEAD"
- git-symbolic-ref "refs/remotes/$origin/HEAD" \
- "refs/remotes/$origin/$head_points_at"
- esac &&
+ "refs/heads/*:$remote_top/*" '^$' &&
+ rm -f "refs/remotes/$origin/HEAD"
+ git-symbolic-ref "refs/remotes/$origin/HEAD" \
+ "refs/remotes/$origin/$head_points_at" &&
+
git-repo-config branch."$head_points_at".remote "$origin" &&
git-repo-config branch."$head_points_at".merge "refs/heads/$head_points_at"
esac
diff --git a/git-compat-util.h b/git-compat-util.h
index 0272d043d..bc296b3a4 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -11,6 +11,11 @@
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
+#define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */
+#define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
+#define _GNU_SOURCE
+#define _BSD_SOURCE
+
#include <unistd.h>
#include <stdio.h>
#include <sys/stat.h>
@@ -22,9 +27,27 @@
#include <errno.h>
#include <limits.h>
#include <sys/param.h>
-#include <netinet/in.h>
#include <sys/types.h>
#include <dirent.h>
+#include <sys/time.h>
+#include <time.h>
+#include <signal.h>
+#include <sys/wait.h>
+#include <fnmatch.h>
+#include <sys/poll.h>
+#include <sys/socket.h>
+#include <assert.h>
+#include <regex.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#include <pwd.h>
+#include <grp.h>
+
+#ifndef NO_ICONV
+#include <iconv.h>
+#endif
/* On most systems <limits.h> would have given us this, but
* not on some systems (e.g. GNU/Hurd).
diff --git a/git-cvsserver.perl b/git-cvsserver.perl
index 2a8447e25..df395126b 100755
--- a/git-cvsserver.perl
+++ b/git-cvsserver.perl
@@ -946,7 +946,7 @@ sub req_update
$log->debug("Temporary directory for merge is $dir");
- my $return = system("git merge-file", $file_local, $file_old, $file_new);
+ my $return = system("git", "merge-file", $file_local, $file_old, $file_new);
$return >>= 8;
if ( $return == 0 )
diff --git a/git-fetch.sh b/git-fetch.sh
index fb35815a5..ffbd44f0e 100755
--- a/git-fetch.sh
+++ b/git-fetch.sh
@@ -96,7 +96,7 @@ fi
# Global that is reused later
ls_remote_result=$(git ls-remote $upload_pack "$remote") ||
- die "Cannot find the reflist at $remote"
+ die "Cannot get the repository state from $remote"
append_fetch_head () {
head_="$1"
@@ -242,7 +242,7 @@ esac
reflist=$(get_remote_refs_for_fetch "$@")
if test "$tags"
then
- taglist=`IFS=" " &&
+ taglist=`IFS=' ' &&
echo "$ls_remote_result" |
while read sha1 name
do
@@ -438,17 +438,11 @@ case "$no_tags$tags" in
*:refs/*)
# effective only when we are following remote branch
# using local tracking branch.
- taglist=$(IFS=" " &&
+ taglist=$(IFS=' ' &&
echo "$ls_remote_result" |
- sed -n -e 's|^\('"$_x40"'\) \(refs/tags/.*\)^{}$|\1 \2|p' \
- -e 's|^\('"$_x40"'\) \(refs/tags/.*\)$|\1 \2|p' |
+ git-show-ref --exclude-existing=refs/tags/ |
while read sha1 name
do
- git-show-ref --verify --quiet -- "$name" && continue
- git-check-ref-format "$name" || {
- echo >&2 "warning: tag ${name} ignored"
- continue
- }
git-cat-file -t "$sha1" >/dev/null 2>&1 || continue
echo >&2 "Auto-following $name"
echo ".${name}:${name}"
diff --git a/git-ls-remote.sh b/git-ls-remote.sh
index 0f88953f2..03b624ef3 100755
--- a/git-ls-remote.sh
+++ b/git-ls-remote.sh
@@ -94,7 +94,7 @@ while read sha1 path
do
case "$sha1" in
failed)
- die "Failed to find remote refs"
+ exit 1 ;;
esac
case "$path" in
refs/heads/*)
diff --git a/git-merge.sh b/git-merge.sh
index c895a04f6..4ebfcf65d 100755
--- a/git-merge.sh
+++ b/git-merge.sh
@@ -91,6 +91,22 @@ finish () {
esac
}
+merge_name () {
+ remote="$1"
+ rh=$(git-rev-parse --verify "$remote^0" 2>/dev/null) || return
+ bh=$(git-show-ref -s --verify "refs/heads/$remote" 2>/dev/null)
+ if test "$rh" = "$bh"
+ then
+ echo "$rh branch '$remote' of ."
+ elif truname=$(expr "$remote" : '\(.*\)~[1-9][0-9]*$') &&
+ git-show-ref -q --verify "refs/heads/$truname" 2>/dev/null
+ then
+ echo "$rh branch '$truname' (early part) of ."
+ else
+ echo "$rh commit '$remote'"
+ fi
+}
+
case "$#" in 0) usage ;; esac
rloga= have_message=
@@ -188,15 +204,7 @@ else
# in this loop.
merge_name=$(for remote
do
- rh=$(git-rev-parse --verify "$remote"^0 2>/dev/null) ||
- continue ;# not something we can merge
- bh=$(git show-ref -s --verify "refs/heads/$remote" 2>/dev/null)
- if test "$rh" = "$bh"
- then
- echo "$rh branch '$remote' of ."
- else
- echo "$rh commit '$remote'"
- fi
+ merge_name "$remote"
done | git-fmt-merge-msg
)
merge_msg="${merge_msg:+$merge_msg$LF$LF}$merge_name"
diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index 6ae534bf8..ea7511e8a 100755
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -111,16 +111,14 @@ expand_refs_wildcard () {
local_force=
test "z$lref" = "z$ref" || local_force='+'
echo "$ls_remote_result" |
+ sed -e '/\^{}$/d' |
(
IFS=' '
while read sha1 name
do
+ # ignore the ones that do not start with $from
mapped=${name#"$from"}
- if test "z$name" != "z${name%'^{}'}" ||
- test "z$name" = "z$mapped"
- then
- continue
- fi
+ test "z$name" = "z$mapped" && continue
echo "${local_force}${name}:${to}${mapped}"
done
)
@@ -134,7 +132,6 @@ canon_refs_list_for_fetch () {
# or the first one otherwise; add prefix . to the rest
# to prevent the secondary branches to be merged by default.
merge_branches=
- found_mergeref=
curr_branch=
if test "$1" = "-d"
then
@@ -144,7 +141,8 @@ canon_refs_list_for_fetch () {
curr_branch=$(git-symbolic-ref HEAD | \
sed -e 's|^refs/heads/||')
merge_branches=$(git-repo-config \
- --get-all "branch.${curr_branch}.merge")
+ --get-all "branch.${curr_branch}.merge") ||
+ merge_branches=.this.would.never.match.any.ref.
fi
set x $(expand_refs_wildcard "$@")
shift
@@ -173,10 +171,6 @@ canon_refs_list_for_fetch () {
dot_prefix= && break
done
fi
- if test -z $dot_prefix
- then
- found_mergeref=true
- fi
case "$remote" in
'') remote=HEAD ;;
refs/heads/* | refs/tags/* | refs/remotes/*) ;;
@@ -197,11 +191,6 @@ canon_refs_list_for_fetch () {
fi
echo "${dot_prefix}${force}${remote}:${local}"
done
- if test -z "$found_mergeref" -a "$curr_branch"
- then
- echo >&2 "Warning: No merge candidate found because value of config option
- \"branch.${curr_branch}.merge\" does not match any remote branch fetched."
- fi
}
# Returns list of src: (no store), or src:dst (store)
diff --git a/git-pull.sh b/git-pull.sh
index e23beb685..1703091bb 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -76,6 +76,10 @@ merge_head=$(sed -e '/ not-for-merge /d' \
case "$merge_head" in
'')
+ curr_branch=$(git-symbolic-ref HEAD | \
+ sed -e 's|^refs/heads/||')
+ echo >&2 "Warning: No merge candidate found because value of config option
+ \"branch.${curr_branch}.merge\" does not match any remote branch fetched."
echo >&2 "No changes."
exit 0
;;
diff --git a/git-rerere.perl b/git-rerere.perl
index fdd685489..4f692091e 100755
--- a/git-rerere.perl
+++ b/git-rerere.perl
@@ -154,7 +154,7 @@ sub find_conflict {
sub merge {
my ($name, $path) = @_;
record_preimage($path, "$rr_dir/$name/thisimage");
- unless (system('git merge-file', map { "$rr_dir/$name/${_}image" }
+ unless (system('git', 'merge-file', map { "$rr_dir/$name/${_}image" }
qw(this pre post))) {
my $in;
open $in, "<$rr_dir/$name/thisimage" or
diff --git a/git.c b/git.c
index 016ee8adb..73cf4d4e0 100644
--- a/git.c
+++ b/git.c
@@ -1,20 +1,8 @@
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <dirent.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-#include <stdarg.h>
-#include "git-compat-util.h"
+#include "builtin.h"
#include "exec_cmd.h"
#include "cache.h"
#include "quote.h"
-#include "builtin.h"
-
const char git_usage_string[] =
"git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate] [--bare] [--git-dir=GIT_DIR] [--help] COMMAND [ARGS]";
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 5ea3fda54..ebbc397ee 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -434,6 +434,7 @@ my %actions = (
"tags" => \&git_tags,
"tree" => \&git_tree,
"snapshot" => \&git_snapshot,
+ "object" => \&git_object,
# those below don't need $project
"opml" => \&git_opml,
"project_list" => \&git_project_list,
@@ -827,14 +828,12 @@ sub format_log_line_html {
my $line = shift;
$line = esc_html($line, -nbsp=>1);
- if ($line =~ m/([0-9a-fA-F]{40})/) {
+ if ($line =~ m/([0-9a-fA-F]{8,40})/) {
my $hash_text = $1;
- if (git_get_type($hash_text) eq "commit") {
- my $link =
- $cgi->a({-href => href(action=>"commit", hash=>$hash_text),
- -class => "text"}, $hash_text);
- $line =~ s/$hash_text/$link/;
- }
+ my $link =
+ $cgi->a({-href => href(action=>"object", hash=>$hash_text),
+ -class => "text"}, $hash_text);
+ $line =~ s/$hash_text/$link/;
}
return $line;
}
@@ -856,7 +855,8 @@ sub format_ref_marker {
$name = $ref;
}
- $markers .= " <span class=\"$type\">" . esc_html($name) . "</span>";
+ $markers .= " <span class=\"$type\" title=\"$ref\">" .
+ esc_html($name) . "</span>";
}
}
@@ -1989,12 +1989,73 @@ sub git_print_log ($;%) {
}
}
+# return link target (what link points to)
+sub git_get_link_target {
+ my $hash = shift;
+ my $link_target;
+
+ # read link
+ open my $fd, "-|", git_cmd(), "cat-file", "blob", $hash
+ or return;
+ {
+ local $/;
+ $link_target = <$fd>;
+ }
+ close $fd
+ or return;
+
+ return $link_target;
+}
+
+# given link target, and the directory (basedir) the link is in,
+# return target of link relative to top directory (top tree);
+# return undef if it is not possible (including absolute links).
+sub normalize_link_target {
+ my ($link_target, $basedir, $hash_base) = @_;
+
+ # we can normalize symlink target only if $hash_base is provided
+ return unless $hash_base;
+
+ # absolute symlinks (beginning with '/') cannot be normalized
+ return if (substr($link_target, 0, 1) eq '/');
+
+ # normalize link target to path from top (root) tree (dir)
+ my $path;
+ if ($basedir) {
+ $path = $basedir . '/' . $link_target;
+ } else {
+ # we are in top (root) tree (dir)
+ $path = $link_target;
+ }
+
+ # remove //, /./, and /../
+ my @path_parts;
+ foreach my $part (split('/', $path)) {
+ # discard '.' and ''
+ next if (!$part || $part eq '.');
+ # handle '..'
+ if ($part eq '..') {
+ if (@path_parts) {
+ pop @path_parts;
+ } else {
+ # link leads outside repository (outside top dir)
+ return;
+ }
+ } else {
+ push @path_parts, $part;
+ }
+ }
+ $path = join('/', @path_parts);
+
+ return $path;
+}
+
# print tree entry (row of git_tree), but without encompassing <tr> element
sub git_print_tree_entry {
my ($t, $basedir, $hash_base, $have_blame) = @_;
my %base_key = ();
- $base_key{hash_base} = $hash_base if defined $hash_base;
+ $base_key{'hash_base'} = $hash_base if defined $hash_base;
# The format of a table row is: mode list link. Where mode is
# the mode of the entry, list is the name of the entry, an href,
@@ -2005,16 +2066,31 @@ sub git_print_tree_entry {
print "<td class=\"list\">" .
$cgi->a({-href => href(action=>"blob", hash=>$t->{'hash'},
file_name=>"$basedir$t->{'name'}", %base_key),
- -class => "list"}, esc_path($t->{'name'})) . "</td>\n";
+ -class => "list"}, esc_path($t->{'name'}));
+ if (S_ISLNK(oct $t->{'mode'})) {
+ my $link_target = git_get_link_target($t->{'hash'});
+ if ($link_target) {
+ my $norm_target = normalize_link_target($link_target, $basedir, $hash_base);
+ if (defined $norm_target) {
+ print " -> " .
+ $cgi->a({-href => href(action=>"object", hash_base=>$hash_base,
+ file_name=>$norm_target),
+ -title => $norm_target}, esc_path($link_target));
+ } else {
+ print " -> " . esc_path($link_target);
+ }
+ }
+ }
+ print "</td>\n";
print "<td class=\"link\">";
print $cgi->a({-href => href(action=>"blob", hash=>$t->{'hash'},
- file_name=>"$basedir$t->{'name'}", %base_key)},
- "blob");
+ file_name=>"$basedir$t->{'name'}", %base_key)},
+ "blob");
if ($have_blame) {
print " | " .
$cgi->a({-href => href(action=>"blame", hash=>$t->{'hash'},
- file_name=>"$basedir$t->{'name'}", %base_key)},
- "blame");
+ file_name=>"$basedir$t->{'name'}", %base_key)},
+ "blame");
}
if (defined $hash_base) {
print " | " .
@@ -2036,8 +2112,8 @@ sub git_print_tree_entry {
print "</td>\n";
print "<td class=\"link\">";
print $cgi->a({-href => href(action=>"tree", hash=>$t->{'hash'},
- file_name=>"$basedir$t->{'name'}", %base_key)},
- "tree");
+ file_name=>"$basedir$t->{'name'}", %base_key)},
+ "tree");
if (defined $hash_base) {
print " | " .
$cgi->a({-href => href(action=>"history", hash_base=>$hash_base,
@@ -2839,8 +2915,10 @@ sub git_summary {
my $owner = git_get_project_owner($project);
my $refs = git_get_references();
- my @taglist = git_get_tags_list(15);
- my @headlist = git_get_heads_list(15);
+ # These get_*_list functions return one more to allow us to see if
+ # there are more ...
+ my @taglist = git_get_tags_list(16);
+ my @headlist = git_get_heads_list(16);
my @forklist;
my ($check_forks) = gitweb_check_feature('forks');
@@ -2876,6 +2954,8 @@ sub git_summary {
}
}
+ # we need to request one more than 16 (0..15) to check if
+ # those 16 are all
open my $fd, "-|", git_cmd(), "rev-list", "--max-count=17",
git_get_head_hash($project), "--"
or die_error(undef, "Open git-rev-list failed");
@@ -2883,17 +2963,20 @@ sub git_summary {
close $fd;
git_print_header_div('shortlog');
git_shortlog_body(\@revlist, 0, 15, $refs,
+ $#revlist <= 15 ? undef :
$cgi->a({-href => href(action=>"shortlog")}, "..."));
if (@taglist) {
git_print_header_div('tags');
git_tags_body(\@taglist, 0, 15,
+ $#taglist <= 15 ? undef :
$cgi->a({-href => href(action=>"tags")}, "..."));
}
if (@headlist) {
git_print_header_div('heads');
git_heads_body(\@headlist, $head, 0, 15,
+ $#headlist <= 15 ? undef :
$cgi->a({-href => href(action=>"heads")}, "..."));
}
@@ -3414,8 +3497,7 @@ sub git_snapshot {
my $filename = basename($project) . "-$hash.tar.$suffix";
print $cgi->header(
- -type => 'application/x-tar',
- -content_encoding => $ctype,
+ -type => "application/$ctype",
-content_disposition => 'inline; filename="' . "$filename" . '"',
-status => '200 OK');
@@ -3497,15 +3579,46 @@ sub git_commit {
my %ad = parse_date($co{'author_epoch'}, $co{'author_tz'});
my %cd = parse_date($co{'committer_epoch'}, $co{'committer_tz'});
- my $parent = $co{'parent'};
+ my $parent = $co{'parent'};
+ my $parents = $co{'parents'}; # listref
+
+ # we need to prepare $formats_nav before any parameter munging
+ my $formats_nav;
+ if (!defined $parent) {
+ # --root commitdiff
+ $formats_nav .= '(initial)';
+ } elsif (@$parents == 1) {
+ # single parent commit
+ $formats_nav .=
+ '(parent: ' .
+ $cgi->a({-href => href(action=>"commit",
+ hash=>$parent)},
+ esc_html(substr($parent, 0, 7))) .
+ ')';
+ } else {
+ # merge commit
+ $formats_nav .=
+ '(merge: ' .
+ join(' ', map {
+ $cgi->a({-href => href(action=>"commitdiff",
+ hash=>$_)},
+ esc_html(substr($_, 0, 7)));
+ } @$parents ) .
+ ')';
+ }
+
if (!defined $parent) {
$parent = "--root";
}
- open my $fd, "-|", git_cmd(), "diff-tree", '-r', "--no-commit-id",
- @diff_opts, $parent, $hash, "--"
- or die_error(undef, "Open git-diff-tree failed");
- my @difftree = map { chomp; $_ } <$fd>;
- close $fd or die_error(undef, "Reading git-diff-tree failed");
+ my @difftree;
+ if (@$parents <= 1) {
+ # difftree output is not printed for merges
+ open my $fd, "-|", git_cmd(), "diff-tree", '-r', "--no-commit-id",
+ @diff_opts, $parent, $hash, "--"
+ or die_error(undef, "Open git-diff-tree failed");
+ @difftree = map { chomp; $_ } <$fd>;
+ close $fd or die_error(undef, "Reading git-diff-tree failed");
+ }
# non-textual hash id's can be cached
my $expires;
@@ -3517,16 +3630,10 @@ sub git_commit {
my $have_snapshot = gitweb_have_snapshot();
- my @views_nav = ();
- if (defined $file_name && defined $co{'parent'}) {
- push @views_nav,
- $cgi->a({-href => href(action=>"blame", hash_parent=>$parent, file_name=>$file_name)},
- "blame");
- }
git_header_html(undef, $expires);
git_print_page_nav('commit', '',
$hash, $co{'tree'}, $hash,
- join (' | ', @views_nav));
+ $formats_nav);
if (defined $co{'parent'}) {
git_print_header_div('commitdiff', esc_html($co{'title'}) . $ref, $hash);
@@ -3567,7 +3674,7 @@ sub git_commit {
}
print "</td>" .
"</tr>\n";
- my $parents = $co{'parents'};
+
foreach my $par (@$parents) {
print "<tr>" .
"<td>parent</td>" .
@@ -3589,11 +3696,61 @@ sub git_commit {
git_print_log($co{'comment'});
print "</div>\n";
- git_difftree_body(\@difftree, $hash, $parent);
+ if (@$parents <= 1) {
+ # do not output difftree/whatchanged for merges
+ git_difftree_body(\@difftree, $hash, $parent);
+ }
git_footer_html();
}
+sub git_object {
+ # object is defined by:
+ # - hash or hash_base alone
+ # - hash_base and file_name
+ my $type;
+
+ # - hash or hash_base alone
+ if ($hash || ($hash_base && !defined $file_name)) {
+ my $object_id = $hash || $hash_base;
+
+ my $git_command = git_cmd_str();
+ open my $fd, "-|", "$git_command cat-file -t $object_id 2>/dev/null"
+ or die_error('404 Not Found', "Object does not exist");
+ $type = <$fd>;
+ chomp $type;
+ close $fd
+ or die_error('404 Not Found', "Object does not exist");
+
+ # - hash_base and file_name
+ } elsif ($hash_base && defined $file_name) {
+ $file_name =~ s,/+$,,;
+
+ system(git_cmd(), "cat-file", '-e', $hash_base) == 0
+ or die_error('404 Not Found', "Base object does not exist");
+
+ # here errors should not hapen
+ open my $fd, "-|", git_cmd(), "ls-tree", $hash_base, "--", $file_name
+ or die_error(undef, "Open git-ls-tree failed");
+ my $line = <$fd>;
+ close $fd;
+
+ #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
+ unless ($line && $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t/) {
+ die_error('404 Not Found', "File or directory for given base does not exist");
+ }
+ $type = $2;
+ $hash = $3;
+ } else {
+ die_error('404 Not Found', "Not enough information to find object");
+ }
+
+ print $cgi->redirect(-uri => href(action=>$type, -full=>1,
+ hash=>$hash, hash_base=>$hash_base,
+ file_name=>$file_name),
+ -status => '302 Found');
+}
+
sub git_blobdiff {
my $format = shift || 'html';
diff --git a/grep.c b/grep.c
index 0fc078ec0..fcc676230 100644
--- a/grep.c
+++ b/grep.c
@@ -1,5 +1,4 @@
#include "cache.h"
-#include <regex.h>
#include "grep.h"
void append_grep_pattern(struct grep_opt *opt, const char *pat,
diff --git a/help.c b/help.c
index 0824c2522..341b9e370 100644
--- a/help.c
+++ b/help.c
@@ -3,12 +3,11 @@
*
* Builtin help-related commands (help, usage, version)
*/
-#include <sys/ioctl.h>
#include "cache.h"
#include "builtin.h"
#include "exec_cmd.h"
#include "common-cmds.h"
-
+#include <sys/ioctl.h>
/* most GUI terminals set COLUMNS (although some don't export it) */
static int term_columns(void)
diff --git a/ident.c b/ident.c
index e415fd358..6ad8fedd6 100644
--- a/ident.c
+++ b/ident.c
@@ -7,9 +7,6 @@
*/
#include "cache.h"
-#include <pwd.h>
-#include <netdb.h>
-
static char git_default_date[50];
static void copy_gecos(struct passwd *w, char *name, int sz)
@@ -221,3 +218,18 @@ const char *git_committer_info(int error_on_no_name)
getenv("GIT_COMMITTER_DATE"),
error_on_no_name);
}
+
+void ignore_missing_committer_name()
+{
+ /* If we did not get a name from the user's gecos entry then
+ * git_default_name is empty; so instead load the username
+ * into it as a 'good enough for now' approximation of who
+ * this user is.
+ */
+ if (!*git_default_name) {
+ struct passwd *pw = getpwuid(getuid());
+ if (!pw)
+ die("You don't exist. Go away!");
+ strlcpy(git_default_name, pw->pw_name, sizeof(git_default_name));
+ }
+}
diff --git a/imap-send.c b/imap-send.c
index a6a65680e..894cbbdf5 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -24,13 +24,6 @@
#include "cache.h"
-#include <assert.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <arpa/inet.h>
-#include <sys/socket.h>
-#include <netdb.h>
-
typedef struct store_conf {
char *name;
const char *path; /* should this be here? its interpretation is driver-specific */
diff --git a/index-pack.c b/index-pack.c
index 6d6c92bf1..5f6d128a8 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -6,8 +6,6 @@
#include "commit.h"
#include "tag.h"
#include "tree.h"
-#include <sys/time.h>
-#include <signal.h>
static const char index_pack_usage[] =
"git-index-pack [-v] [-o <index-file>] [{ ---keep | --keep=<msg> }] { <pack-file> | --stdin [--fix-thin] [<pack-file>] }";
@@ -87,7 +85,7 @@ static unsigned display_progress(unsigned n, unsigned total, unsigned last_pc)
static unsigned char input_buffer[4096];
static unsigned long input_offset, input_len, consumed_bytes;
static SHA_CTX input_ctx;
-static int input_fd, output_fd, mmap_fd;
+static int input_fd, output_fd, pack_fd;
/* Discard current buffer used content. */
static void flush(void)
@@ -148,14 +146,14 @@ static const char *open_pack_file(const char *pack_name)
output_fd = open(pack_name, O_CREAT|O_EXCL|O_RDWR, 0600);
if (output_fd < 0)
die("unable to create %s: %s\n", pack_name, strerror(errno));
- mmap_fd = output_fd;
+ pack_fd = output_fd;
} else {
input_fd = open(pack_name, O_RDONLY);
if (input_fd < 0)
die("cannot open packfile '%s': %s",
pack_name, strerror(errno));
output_fd = -1;
- mmap_fd = input_fd;
+ pack_fd = input_fd;
}
SHA1_Init(&input_ctx);
return pack_name;
@@ -268,7 +266,7 @@ static void *unpack_raw_entry(struct object_entry *obj, union delta_base *delta_
case OBJ_TAG:
break;
default:
- bad_object(obj->offset, "bad object type %d", obj->type);
+ bad_object(obj->offset, "unknown object type %d", obj->type);
}
obj->hdr_size = consumed_bytes - obj->offset;
@@ -279,27 +277,25 @@ static void *get_data_from_pack(struct object_entry *obj)
{
unsigned long from = obj[0].offset + obj[0].hdr_size;
unsigned long len = obj[1].offset - from;
- unsigned pg_offset = from % getpagesize();
- unsigned char *map, *data;
+ unsigned char *src, *data;
z_stream stream;
int st;
- map = mmap(NULL, len + pg_offset, PROT_READ, MAP_PRIVATE,
- mmap_fd, from - pg_offset);
- if (map == MAP_FAILED)
- die("cannot mmap pack file: %s", strerror(errno));
+ src = xmalloc(len);
+ if (pread(pack_fd, src, len, from) != len)
+ die("cannot pread pack file: %s", strerror(errno));
data = xmalloc(obj->size);
memset(&stream, 0, sizeof(stream));
stream.next_out = data;
stream.avail_out = obj->size;
- stream.next_in = map + pg_offset;
+ stream.next_in = src;
stream.avail_in = len;
inflateInit(&stream);
while ((st = inflate(&stream, Z_FINISH)) == Z_OK);
inflateEnd(&stream);
if (st != Z_STREAM_END || stream.total_out != obj->size)
die("serious inflate inconsistency");
- munmap(map, len + pg_offset);
+ free(src);
return data;
}
diff --git a/interpolate.c b/interpolate.c
index 5d9d1889f..f992ef775 100644
--- a/interpolate.c
+++ b/interpolate.c
@@ -2,8 +2,6 @@
* Copyright 2006 Jon Loeliger
*/
-#include <string.h>
-
#include "git-compat-util.h"
#include "interpolate.h"
diff --git a/lockfile.c b/lockfile.c
index 2a2fea3cb..261baff04 100644
--- a/lockfile.c
+++ b/lockfile.c
@@ -1,7 +1,6 @@
/*
* Copyright (c) 2005, Junio C Hamano
*/
-#include <signal.h>
#include "cache.h"
static struct lock_file *lock_file_list;
diff --git a/log-tree.c b/log-tree.c
index 8787df5cc..35be33aaf 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -114,6 +114,14 @@ void show_log(struct rev_info *opt, const char *sep)
opt->loginfo = NULL;
if (!opt->verbose_header) {
+ if (opt->left_right) {
+ if (commit->object.flags & BOUNDARY)
+ putchar('-');
+ else if (commit->object.flags & SYMMETRIC_LEFT)
+ putchar('<');
+ else
+ putchar('>');
+ }
fputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit), stdout);
if (opt->parents)
show_parents(commit, abbrev_commit);
@@ -192,10 +200,20 @@ void show_log(struct rev_info *opt, const char *sep)
opt->diffopt.stat_sep = buffer;
}
} else {
- printf("%s%s%s",
- diff_get_color(opt->diffopt.color_diff, DIFF_COMMIT),
- opt->commit_format == CMIT_FMT_ONELINE ? "" : "commit ",
- diff_unique_abbrev(commit->object.sha1, abbrev_commit));
+ fputs(diff_get_color(opt->diffopt.color_diff, DIFF_COMMIT),
+ stdout);
+ if (opt->commit_format != CMIT_FMT_ONELINE)
+ fputs("commit ", stdout);
+ if (opt->left_right) {
+ if (commit->object.flags & BOUNDARY)
+ putchar('-');
+ else if (commit->object.flags & SYMMETRIC_LEFT)
+ putchar('<');
+ else
+ putchar('>');
+ }
+ fputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit),
+ stdout);
if (opt->parents)
show_parents(commit, abbrev_commit);
if (parent)
diff --git a/merge-base.c b/merge-base.c
index 009caf804..385f4ba38 100644
--- a/merge-base.c
+++ b/merge-base.c
@@ -1,4 +1,3 @@
-#include <stdlib.h>
#include "cache.h"
#include "commit.h"
diff --git a/merge-index.c b/merge-index.c
index 646d090c5..a9983dd78 100644
--- a/merge-index.c
+++ b/merge-index.c
@@ -1,7 +1,3 @@
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <signal.h>
-
#include "cache.h"
static const char *pgm;
diff --git a/merge-recursive.c b/merge-recursive.c
index 6dd6e2e5a..ae7ae4cd2 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -3,13 +3,6 @@
* Fredrik Kuivinen.
* The thieves were Alex Riesen and Johannes Schindelin, in June/July 2006
*/
-#include <stdarg.h>
-#include <string.h>
-#include <assert.h>
-#include <sys/wait.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <time.h>
#include "cache.h"
#include "cache-tree.h"
#include "commit.h"
@@ -1279,7 +1272,7 @@ int main(int argc, char *argv[])
struct commit *result, *h1, *h2;
git_config(git_default_config); /* core.filemode */
- original_index_file = getenv("GIT_INDEX_FILE");
+ original_index_file = getenv(INDEX_ENVIRONMENT);
if (!original_index_file)
original_index_file = xstrdup(git_path("index"));
diff --git a/patch-delta.c b/patch-delta.c
index e3a1d425e..ed9db81fa 100644
--- a/patch-delta.c
+++ b/patch-delta.c
@@ -9,8 +9,7 @@
* published by the Free Software Foundation.
*/
-#include <stdlib.h>
-#include <string.h>
+#include "git-compat-util.h"
#include "delta.h"
void *patch_delta(const void *src_buf, unsigned long src_size,
@@ -34,9 +33,7 @@ void *patch_delta(const void *src_buf, unsigned long src_size,
/* now the result size */
size = get_delta_hdr_size(&data, top);
- dst_buf = malloc(size + 1);
- if (!dst_buf)
- return NULL;
+ dst_buf = xmalloc(size + 1);
dst_buf[size] = 0;
out = dst_buf;
@@ -55,13 +52,13 @@ void *patch_delta(const void *src_buf, unsigned long src_size,
if (cp_off + cp_size < cp_size ||
cp_off + cp_size > src_size ||
cp_size > size)
- goto bad;
+ break;
memcpy(out, (char *) src_buf + cp_off, cp_size);
out += cp_size;
size -= cp_size;
} else if (cmd) {
if (cmd > size)
- goto bad;
+ break;
memcpy(out, data, cmd);
out += cmd;
data += cmd;
@@ -72,12 +69,14 @@ void *patch_delta(const void *src_buf, unsigned long src_size,
* extensions. In the mean time we must fail when
* encountering them (might be data corruption).
*/
+ error("unexpected delta opcode 0");
goto bad;
}
}
/* sanity check */
if (data != top || size != 0) {
+ error("delta replay has gone wild");
bad:
free(dst_buf);
return NULL;
diff --git a/path-list.c b/path-list.c
index f8800f8e6..caaa5cc57 100644
--- a/path-list.c
+++ b/path-list.c
@@ -1,4 +1,3 @@
-#include <stdio.h>
#include "cache.h"
#include "path-list.h"
diff --git a/path.c b/path.c
index d2c076d7c..066f62195 100644
--- a/path.c
+++ b/path.c
@@ -11,7 +11,6 @@
* which is what it's designed for.
*/
#include "cache.h"
-#include <pwd.h>
static char bad_path[] = "/bad-path/";
diff --git a/pkt-line.c b/pkt-line.c
index c1e81f976..b4cb7e275 100644
--- a/pkt-line.c
+++ b/pkt-line.c
@@ -72,7 +72,7 @@ static void safe_read(int fd, void *buffer, unsigned size)
if (ret < 0)
die("read error (%s)", strerror(errno));
if (!ret)
- die("unexpected EOF");
+ die("The remote end hung up unexpectedly");
n += ret;
}
}
diff --git a/read-cache.c b/read-cache.c
index eae4745d2..b8d83ccd9 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -358,7 +358,7 @@ int add_file_to_index(const char *path, int verbose)
if (index_path(ce->sha1, path, &st, 1))
die("unable to index file %s", path);
- if (add_cache_entry(ce, ADD_CACHE_OK_TO_ADD))
+ if (add_cache_entry(ce, ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE))
die("unable to add %s to index",path);
if (verbose)
printf("add '%s'\n", path);
@@ -517,7 +517,7 @@ static int has_dir_name(const struct cache_entry *ce, int pos, int ok_to_replace
pos = cache_name_pos(name, ntohs(create_ce_flags(len, stage)));
if (pos >= 0) {
retval = -1;
- if (ok_to_replace)
+ if (!ok_to_replace)
break;
remove_cache_entry_at(pos);
continue;
@@ -609,7 +609,7 @@ int add_cache_entry(struct cache_entry *ce, int option)
if (!skip_df_check &&
check_file_directory_conflict(ce, pos, ok_to_replace)) {
if (!ok_to_replace)
- return -1;
+ return error("'%s' appears as both a file and as a directory", ce->name);
pos = cache_name_pos(ce->name, ntohs(ce->ce_flags));
pos = -pos-1;
}
diff --git a/receive-pack.c b/receive-pack.c
index e76d9aea3..59b682c03 100644
--- a/receive-pack.c
+++ b/receive-pack.c
@@ -6,7 +6,6 @@
#include "exec_cmd.h"
#include "commit.h"
#include "object.h"
-#include <sys/wait.h>
static const char receive_pack_usage[] = "git-receive-pack <git-dir>";
@@ -420,6 +419,8 @@ int main(int argc, char **argv)
die("'%s': unable to chdir or not a git archive", dir);
setup_ident();
+ /* don't die if gecos is empty */
+ ignore_missing_committer_name();
git_config(receive_pack_config);
write_head_info();
diff --git a/refs.c b/refs.c
index a02957c39..a101ff3bf 100644
--- a/refs.c
+++ b/refs.c
@@ -1,10 +1,8 @@
-#include "refs.h"
#include "cache.h"
+#include "refs.h"
#include "object.h"
#include "tag.h"
-#include <errno.h>
-
/* ISSYMREF=01 and ISPACKED=02 are public interfaces */
#define REF_KNOWS_PEELED 04
@@ -867,6 +865,16 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)
goto rollback;
}
+ if (!strncmp(oldref, "refs/heads/", 11) &&
+ !strncmp(newref, "refs/heads/", 11)) {
+ char oldsection[1024], newsection[1024];
+
+ snprintf(oldsection, 1024, "branch.%s", oldref + 11);
+ snprintf(newsection, 1024, "branch.%s", newref + 11);
+ if (git_config_rename_section(oldsection, newsection) < 0)
+ return 1;
+ }
+
return 0;
rollback:
diff --git a/revision.c b/revision.c
index 993bb668a..4dae5342e 100644
--- a/revision.c
+++ b/revision.c
@@ -6,7 +6,6 @@
#include "diff.h"
#include "refs.h"
#include "revision.h"
-#include <regex.h>
#include "grep.h"
static char *path_name(struct name_path *path, const char *name)
@@ -344,6 +343,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
static void add_parents_to_list(struct rev_info *revs, struct commit *commit, struct commit_list **list)
{
struct commit_list *parent = commit->parents;
+ unsigned left_flag;
if (commit->object.flags & ADDED)
return;
@@ -388,6 +388,7 @@ static void add_parents_to_list(struct rev_info *revs, struct commit *commit, st
if (revs->no_walk)
return;
+ left_flag = (commit->object.flags & SYMMETRIC_LEFT);
parent = commit->parents;
while (parent) {
struct commit *p = parent->item;
@@ -395,6 +396,7 @@ static void add_parents_to_list(struct rev_info *revs, struct commit *commit, st
parent = parent->next;
parse_commit(p);
+ p->object.flags |= left_flag;
if (p->object.flags & SEEN)
continue;
p->object.flags |= SEEN;
@@ -640,7 +642,7 @@ int handle_revision_arg(const char *arg, struct rev_info *revs,
add_pending_commit_list(revs, exclude,
flags_exclude);
free_commit_list(exclude);
- a->object.flags |= flags;
+ a->object.flags |= flags | SYMMETRIC_LEFT;
} else
a->object.flags |= flags_exclude;
b->object.flags |= flags;
@@ -850,6 +852,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
revs->boundary = 1;
continue;
}
+ if (!strcmp(arg, "--left-right")) {
+ revs->left_right = 1;
+ continue;
+ }
if (!strcmp(arg, "--objects")) {
revs->tag_objects = 1;
revs->tree_objects = 1;
diff --git a/revision.h b/revision.h
index 3adab9590..4585463a4 100644
--- a/revision.h
+++ b/revision.h
@@ -9,6 +9,7 @@
#define BOUNDARY (1u<<5)
#define BOUNDARY_SHOW (1u<<6)
#define ADDED (1u<<7) /* Parents already parsed and added? */
+#define SYMMETRIC_LEFT (1u<<8)
struct rev_info;
struct log_info;
@@ -40,6 +41,7 @@ struct rev_info {
limited:1,
unpacked:1, /* see also ignore_packed below */
boundary:1,
+ left_right:1,
parents:1;
/* Diff flags */
diff --git a/rsh.c b/rsh.c
index f34409e1b..5754a230e 100644
--- a/rsh.c
+++ b/rsh.c
@@ -1,10 +1,6 @@
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-
+#include "cache.h"
#include "rsh.h"
#include "quote.h"
-#include "cache.h"
#define COMMAND_SIZE 4096
diff --git a/run-command.c b/run-command.c
index 61908682b..492ad3e64 100644
--- a/run-command.c
+++ b/run-command.c
@@ -1,6 +1,5 @@
#include "cache.h"
#include "run-command.h"
-#include <sys/wait.h>
#include "exec_cmd.h"
int run_command_v_opt(int argc, const char **argv, int flags)
diff --git a/sha1_file.c b/sha1_file.c
index 63f416bb5..1c4df5b73 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1013,7 +1013,7 @@ void packed_object_info_detail(struct packed_git *p,
for (;;) {
switch (kind) {
default:
- die("corrupted pack file %s containing object of kind %d",
+ die("pack %s contains unknown object type %d",
p->pack_name, kind);
case OBJ_COMMIT:
case OBJ_TREE:
@@ -1063,7 +1063,7 @@ static int packed_object_info(struct packed_git *p, unsigned long offset,
strcpy(type, type_names[kind]);
break;
default:
- die("corrupted pack file %s containing object of kind %d",
+ die("pack %s contains unknown object type %d",
p->pack_name, kind);
}
if (sizep)
diff --git a/ssh-upload.c b/ssh-upload.c
index 20b15eab5..0b52ae15c 100644
--- a/ssh-upload.c
+++ b/ssh-upload.c
@@ -12,8 +12,6 @@
#include "rsh.h"
#include "refs.h"
-#include <string.h>
-
static unsigned char local_version = 1;
static unsigned char remote_version;
diff --git a/strbuf.c b/strbuf.c
index 9d9d8bed9..7f14b0fb5 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -1,7 +1,5 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include "strbuf.h"
#include "cache.h"
+#include "strbuf.h"
void strbuf_init(struct strbuf *sb) {
sb->buf = NULL;
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 3260d1d7a..0cd1c4186 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -272,4 +272,13 @@ test_expect_success \
wc -l) &&
test $numparent = 1'
+test_expect_success 'update-index D/F conflict' '
+ mv path0 tmp &&
+ mv path2 path0 &&
+ mv tmp path2 &&
+ git update-index --add --replace path2 path0/file2 &&
+ numpath0=$(git ls-files path0 | wc -l) &&
+ test $numpath0 = 1
+'
+
test_done
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index 16cd64261..e48a4ecdc 100755
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -343,5 +343,53 @@ EOF
test_expect_success '--set in alternative GIT_CONFIG' 'cmp other-config expect'
+cat > .git/config << EOF
+# Hallo
+ #Bello
+[branch "eins"]
+ x = 1
+[branch.eins]
+ y = 1
+ [branch "1 234 blabl/a"]
+weird
+EOF
+
+test_expect_success "rename section" \
+ "git-repo-config --rename-section branch.eins branch.zwei"
+
+cat > expect << EOF
+# Hallo
+ #Bello
+[branch "zwei"]
+ x = 1
+[branch "zwei"]
+ y = 1
+ [branch "1 234 blabl/a"]
+weird
+EOF
+
+test_expect_success "rename succeeded" "diff -u expect .git/config"
+
+test_expect_failure "rename non-existing section" \
+ 'git-repo-config --rename-section branch."world domination" branch.drei'
+
+test_expect_success "rename succeeded" "diff -u expect .git/config"
+
+test_expect_success "rename another section" \
+ 'git-repo-config --rename-section branch."1 234 blabl/a" branch.drei'
+
+cat > expect << EOF
+# Hallo
+ #Bello
+[branch "zwei"]
+ x = 1
+[branch "zwei"]
+ y = 1
+[branch "drei"]
+weird
+EOF
+
+test_expect_success "rename succeeded" "diff -u expect .git/config"
+
test_done
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index 5782c30b0..a6ea0f6a1 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -94,6 +94,8 @@ test_expect_failure \
git-branch r &&
git-branch -m q r/q'
+git-repo-config branch.s/s.dummy Hello
+
test_expect_success \
'git branch -m s/s s should work when s/t is deleted' \
'git-branch -l s/s &&
@@ -104,6 +106,10 @@ test_expect_success \
git-branch -m s/s s &&
test -f .git/logs/refs/heads/s'
+test_expect_success 'config information was renamed, too' \
+ "test $(git-repo-config branch.s.dummy) = Hello &&
+ ! git-repo-config branch.s/s/dummy"
+
test_expect_failure \
'git-branch -m u v should fail when the reflog for u is a symlink' \
'git-branch -l u &&
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index a11ab0ad4..90eeeba2a 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -23,15 +23,14 @@ test_expect_success "clone and setup child repos" '
git clone . two &&
cd two &&
git repo-config branch.master.remote one &&
- {
- echo "URL: ../one/.git/"
- echo "Pull: refs/heads/master:refs/heads/one"
- } >.git/remotes/one
+ git repo-config remote.one.url ../one/.git/ &&
+ git repo-config remote.one.fetch refs/heads/master:refs/heads/one &&
cd .. &&
git clone . three &&
cd three &&
git repo-config branch.master.remote two &&
git repo-config branch.master.merge refs/heads/one &&
+ mkdir -p .git/remotes &&
{
echo "URL: ../two/.git/"
echo "Pull: refs/heads/master:refs/heads/two"
diff --git a/t/test-lib.sh b/t/test-lib.sh
index ac7be769b..f0f9cd6be 100755
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -208,8 +208,9 @@ test_done () {
# t/ subdirectory and are run in trash subdirectory.
PATH=$(pwd)/..:$PATH
GIT_EXEC_PATH=$(pwd)/..
+GIT_TEMPLATE_DIR=$(pwd)/../templates/blt
HOME=$(pwd)/trash
-export PATH GIT_EXEC_PATH HOME
+export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR HOME
GITPERLLIB=$(pwd)/../perl/blib/lib:$(pwd)/../perl/blib/arch/auto/Git
export GITPERLLIB
diff --git a/templates/remotes-- b/templates/remotes--
deleted file mode 100644
index fae88709a..000000000
--- a/templates/remotes--
+++ /dev/null
@@ -1 +0,0 @@
-: this is just to ensure the directory exists.
diff --git a/test-date.c b/test-date.c
index 93e802759..62e8f2387 100644
--- a/test-date.c
+++ b/test-date.c
@@ -1,6 +1,3 @@
-#include <stdio.h>
-#include <time.h>
-
#include "cache.h"
int main(int argc, char **argv)
diff --git a/test-delta.c b/test-delta.c
index 1be8ee0c7..795aa0837 100644
--- a/test-delta.c
+++ b/test-delta.c
@@ -8,13 +8,7 @@
* published by the Free Software Foundation.
*/
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
+#include "git-compat-util.h"
#include "delta.h"
static const char usage[] =
diff --git a/tree.c b/tree.c
index ea386e506..b6f02fecc 100644
--- a/tree.c
+++ b/tree.c
@@ -4,7 +4,6 @@
#include "commit.h"
#include "tag.h"
#include "tree-walk.h"
-#include <stdlib.h>
const char *tree_type = "tree";
diff --git a/unpack-trees.c b/unpack-trees.c
index b8689ebc8..2e2232cbb 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1,5 +1,3 @@
-#include <signal.h>
-#include <sys/time.h>
#include "cache.h"
#include "dir.h"
#include "tree.h"
diff --git a/upload-pack.c b/upload-pack.c
index 4572fff07..32b06b2e6 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -1,6 +1,3 @@
-#include <signal.h>
-#include <sys/wait.h>
-#include <sys/poll.h>
#include "cache.h"
#include "refs.h"
#include "pkt-line.h"
diff --git a/var.c b/var.c
index a57a33b81..39977b949 100644
--- a/var.c
+++ b/var.c
@@ -4,9 +4,6 @@
* Copyright (C) Eric Biederman, 2005
*/
#include "cache.h"
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
static const char var_usage[] = "git-var [-l | <variable>]";
diff --git a/wt-status.c b/wt-status.c
index c388ce129..db427384f 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1,6 +1,6 @@
+#include "cache.h"
#include "wt-status.h"
#include "color.h"
-#include "cache.h"
#include "object.h"
#include "dir.h"
#include "commit.h"
@@ -271,7 +271,7 @@ static void wt_status_print_verbose(struct wt_status *s)
void wt_status_print(struct wt_status *s)
{
- if (s->branch && strcmp(s->branch, "refs/heads/master"))
+ if (s->branch)
color_printf_ln(color(WT_STATUS_HEADER),
"# On branch %s", s->branch);