summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/config.txt5
-rw-r--r--Documentation/core-intro.txt2
-rw-r--r--Documentation/git-rerere.txt4
-rw-r--r--Documentation/git-submodule.txt7
-rw-r--r--Documentation/user-manual.txt14
-rw-r--r--builtin-apply.c6
-rw-r--r--builtin-branch.c2
-rw-r--r--builtin-rerere.c32
-rw-r--r--contrib/emacs/git.el3
-rw-r--r--diff-lib.c2
-rwxr-xr-xgit-am.sh15
-rwxr-xr-xgit-commit.sh5
-rwxr-xr-xgit-cvsserver.perl8
-rwxr-xr-xgit-merge.sh5
-rwxr-xr-xgit-rebase.sh12
-rwxr-xr-xgit-send-email.perl2
-rwxr-xr-xgit-stash.sh1
-rwxr-xr-xt/t4116-apply-reverse.sh6
-rwxr-xr-xt/t4200-rerere.sh23
19 files changed, 96 insertions, 58 deletions
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 66a55b0514..4b67f0adf7 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -448,6 +448,11 @@ gc.rerereunresolved::
kept for this many days when `git rerere gc` is run.
The default is 15 days. See gitlink:git-rerere[1].
+rerere.enabled::
+ Activate recording of resolved conflicts, so that identical
+ conflict hunks can be resolved automatically, should they
+ be encountered again. See gitlink:git-rerere[1].
+
gitcvs.enabled::
Whether the cvs server interface is enabled for this repository.
See gitlink:git-cvsserver[1].
diff --git a/Documentation/core-intro.txt b/Documentation/core-intro.txt
index eea44d9d56..f3cc2238c7 100644
--- a/Documentation/core-intro.txt
+++ b/Documentation/core-intro.txt
@@ -528,7 +528,7 @@ paths that have been trivially merged.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sadly, many merges aren't trivial. If there are files that have
-been added.moved or removed, or if both branches have modified the
+been added, moved or removed, or if both branches have modified the
same file, you will be left with an index tree that contains "merge
entries" in it. Such an index tree can 'NOT' be written out to a tree
object, and you will have to resolve any such merge clashes using
diff --git a/Documentation/git-rerere.txt b/Documentation/git-rerere.txt
index 7ff9b05e68..c4d4263238 100644
--- a/Documentation/git-rerere.txt
+++ b/Documentation/git-rerere.txt
@@ -23,7 +23,7 @@ initial manual merge, and later by noticing the same automerge
results and applying the previously recorded hand resolution.
[NOTE]
-You need to create `$GIT_DIR/rr-cache` directory to enable this
+You need to set the config variable rerere.enabled to enable this
command.
@@ -171,7 +171,7 @@ records it if it is a new conflict, or reuses the earlier hand
resolve when it is not. `git-commit` also invokes `git-rerere`
when recording a merge result. What this means is that you do
not have to do anything special yourself (Note: you still have
-to create `$GIT_DIR/rr-cache` directory to enable this command).
+to set the config variable rerere.enabled to enable this command).
In our example, when you did the test merge, the manual
resolution is recorded, and it will be reused when you do the
diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
index 7f0904e293..2c48936fcd 100644
--- a/Documentation/git-submodule.txt
+++ b/Documentation/git-submodule.txt
@@ -8,6 +8,7 @@ git-submodule - Initialize, update or inspect submodules
SYNOPSIS
--------
+[verse]
'git-submodule' [--quiet] [-b branch] add <repository> [<path>]
'git-submodule' [--quiet] [--cached] [status|init|update] [--] [<path>...]
@@ -32,8 +33,8 @@ status::
init::
Initialize the submodules, i.e. register in .git/config each submodule
- path and url found in .gitmodules. The key used in git/config is
- `submodule.$path.url`. This command does not alter existing information
+ name and url found in .gitmodules. The key used in .git/config is
+ `submodule.$name.url`. This command does not alter existing information
in .git/config.
update::
@@ -64,7 +65,7 @@ FILES
When initializing submodules, a .gitmodules file in the top-level directory
of the containing repository is used to find the url of each submodule.
This file should be formatted in the same way as $GIR_DIR/config. The key
-to each submodule url is "module.$path.url".
+to each submodule url is "submodule.$name.url".
AUTHOR
diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt
index ff7c71d4fb..c23077c724 100644
--- a/Documentation/user-manual.txt
+++ b/Documentation/user-manual.txt
@@ -2957,13 +2957,13 @@ developed. If you blow the directory cache away entirely, you generally
haven't lost any information as long as you have the name of the tree
that it described.
-At the same time, the index is at the same time also the
-staging area for creating new trees, and creating a new tree always
-involves a controlled modification of the index file. In particular,
-the index file can have the representation of an intermediate tree that
-has not yet been instantiated. So the index can be thought of as a
-write-back cache, which can contain dirty information that has not yet
-been written back to the backing store.
+At the same time, the index is also the staging area for creating
+new trees, and creating a new tree always involves a controlled
+modification of the index file. In particular, the index file can
+have the representation of an intermediate tree that has not yet been
+instantiated. So the index can be thought of as a write-back cache,
+which can contain dirty information that has not yet been written back
+to the backing store.
diff --git a/builtin-apply.c b/builtin-apply.c
index c6f736c14e..0a0b4a9e3f 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -1003,12 +1003,16 @@ static int parse_fragment(char *line, unsigned long size, struct patch *patch, s
trailing++;
break;
case '-':
+ if (apply_in_reverse &&
+ new_whitespace != nowarn_whitespace)
+ check_whitespace(line, len);
deleted++;
oldlines--;
trailing = 0;
break;
case '+':
- if (new_whitespace != nowarn_whitespace)
+ if (!apply_in_reverse &&
+ new_whitespace != nowarn_whitespace)
check_whitespace(line, len);
added++;
newlines--;
diff --git a/builtin-branch.c b/builtin-branch.c
index 77b85dde1f..84a8ad7b73 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -22,7 +22,7 @@ static const char builtin_branch_usage[] =
static const char *head;
static unsigned char head_sha1[20];
-static int branch_track_remotes;
+static int branch_track_remotes = 1;
static int branch_use_color;
static char branch_colors[][COLOR_MAXLEN] = {
diff --git a/builtin-rerere.c b/builtin-rerere.c
index 01f3848f14..c25b3d5586 100644
--- a/builtin-rerere.c
+++ b/builtin-rerere.c
@@ -12,6 +12,9 @@ static const char git_rerere_usage[] =
static int cutoff_noresolve = 15;
static int cutoff_resolve = 60;
+/* if rerere_enabled == -1, fall back to detection of .git/rr-cache */
+static int rerere_enabled = -1;
+
static char *merge_rr_path;
static const char *rr_path(const char *name, const char *file)
@@ -387,21 +390,41 @@ static int git_rerere_config(const char *var, const char *value)
cutoff_resolve = git_config_int(var, value);
else if (!strcmp(var, "gc.rerereunresolved"))
cutoff_noresolve = git_config_int(var, value);
+ else if (!strcmp(var, "rerere.enabled"))
+ rerere_enabled = git_config_bool(var, value);
else
return git_default_config(var, value);
return 0;
}
-int cmd_rerere(int argc, const char **argv, const char *prefix)
+static int is_rerere_enabled(void)
{
- struct path_list merge_rr = { NULL, 0, 0, 1 };
- int i, fd = -1;
struct stat st;
+ const char *rr_cache;
+ int rr_cache_exists;
- if (stat(git_path("rr-cache"), &st) || !S_ISDIR(st.st_mode))
+ if (!rerere_enabled)
return 0;
+ rr_cache = git_path("rr-cache");
+ rr_cache_exists = !stat(rr_cache, &st) && S_ISDIR(st.st_mode);
+ if (rerere_enabled < 0)
+ return rr_cache_exists;
+
+ if (!rr_cache_exists &&
+ (mkdir(rr_cache, 0777) || adjust_shared_perm(rr_cache)))
+ die("Could not create directory %s", rr_cache);
+ return 1;
+}
+
+int cmd_rerere(int argc, const char **argv, const char *prefix)
+{
+ struct path_list merge_rr = { NULL, 0, 0, 1 };
+ int i, fd = -1;
+
git_config(git_rerere_config);
+ if (!is_rerere_enabled())
+ return 0;
merge_rr_path = xstrdup(git_path("rr-cache/MERGE_RR"));
fd = hold_lock_file_for_update(&write_lock, merge_rr_path, 1);
@@ -411,6 +434,7 @@ int cmd_rerere(int argc, const char **argv, const char *prefix)
return do_plain_rerere(&merge_rr, fd);
else if (!strcmp(argv[1], "clear")) {
for (i = 0; i < merge_rr.nr; i++) {
+ struct stat st;
const char *name = (const char *)merge_rr.items[i].util;
if (!stat(git_path("rr-cache/%s", name), &st) &&
S_ISDIR(st.st_mode) &&
diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el
index f60017948f..457f95fc05 100644
--- a/contrib/emacs/git.el
+++ b/contrib/emacs/git.el
@@ -681,8 +681,7 @@ and returns the process output as a string."
(condition-case nil (delete-file ".git/MERGE_MSG") (error nil))
(with-current-buffer buffer (erase-buffer))
(git-set-files-state files 'uptodate)
- (when (file-directory-p ".git/rr-cache")
- (git-run-command nil nil "rerere"))
+ (git-run-command nil nil "rerere")
(git-refresh-files)
(git-refresh-ewoc-hf git-status)
(message "Committed %s." commit)
diff --git a/diff-lib.c b/diff-lib.c
index 7fb19c7b87..92c0e39ad6 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -24,7 +24,7 @@ static int read_directory(const char *path, struct path_list *list)
while ((e = readdir(dir)))
if (strcmp(".", e->d_name) && strcmp("..", e->d_name))
- path_list_insert(xstrdup(e->d_name), list);
+ path_list_insert(e->d_name, list);
closedir(dir);
return 0;
diff --git a/git-am.sh b/git-am.sh
index d57a3e2d09..e5e6f2c91c 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -95,10 +95,7 @@ It does not apply to blobs recorded in its index."
eval GITHEAD_$his_tree='"$SUBJECT"'
export GITHEAD_$his_tree
git-merge-recursive $orig_tree -- HEAD $his_tree || {
- if test -d "$GIT_DIR/rr-cache"
- then
- git rerere
- fi
+ git rerere
echo Failed to merge in the changes.
exit 1
}
@@ -252,10 +249,7 @@ last=`cat "$dotest/last"`
this=`cat "$dotest/next"`
if test "$skip" = t
then
- if test -d "$GIT_DIR/rr-cache"
- then
- git rerere clear
- fi
+ git rerere clear
this=`expr "$this" + 1`
resume=
fi
@@ -420,10 +414,7 @@ do
stop_here_user_resolve $this
fi
apply_status=0
- if test -d "$GIT_DIR/rr-cache"
- then
- git rerere
- fi
+ git rerere
;;
esac
diff --git a/git-commit.sh b/git-commit.sh
index f866f957c4..9106a743cc 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -610,10 +610,7 @@ rm -f "$GIT_DIR/COMMIT_MSG" "$GIT_DIR/COMMIT_EDITMSG" "$GIT_DIR/SQUASH_MSG"
cd_to_toplevel
-if test -d "$GIT_DIR/rr-cache"
-then
- git rerere
-fi
+git rerere
if test "$ret" = 0
then
diff --git a/git-cvsserver.perl b/git-cvsserver.perl
index 5cbf27eebc..10aba507d7 100755
--- a/git-cvsserver.perl
+++ b/git-cvsserver.perl
@@ -1813,14 +1813,14 @@ sub req_annotate
# the second is $state->{files} which is everything after it.
sub argsplit
{
- return unless( defined($state->{arguments}) and ref $state->{arguments} eq "ARRAY" );
-
- my $type = shift;
-
$state->{args} = [];
$state->{files} = [];
$state->{opt} = {};
+ return unless( defined($state->{arguments}) and ref $state->{arguments} eq "ARRAY" );
+
+ my $type = shift;
+
if ( defined($type) )
{
my $opt = {};
diff --git a/git-merge.sh b/git-merge.sh
index 485253032a..5ccf28251d 100755
--- a/git-merge.sh
+++ b/git-merge.sh
@@ -496,9 +496,6 @@ Conflicts:
sed -e 's/^[^ ]* / /' |
uniq
} >>"$GIT_DIR/MERGE_MSG"
- if test -d "$GIT_DIR/rr-cache"
- then
- git rerere
- fi
+ git rerere
die "Automatic merge failed; fix conflicts and then commit the result."
fi
diff --git a/git-rebase.sh b/git-rebase.sh
index 7a02f2975d..cbafa14ed5 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -101,7 +101,7 @@ call_merge () {
return
;;
1)
- test -d "$GIT_DIR/rr-cache" && git rerere
+ git rerere
die "$RESOLVEMSG"
;;
2)
@@ -160,10 +160,7 @@ do
--skip)
if test -d "$dotest"
then
- if test -d "$GIT_DIR/rr-cache"
- then
- git rerere clear
- fi
+ git rerere clear
prev_head="`cat $dotest/prev_head`"
end="`cat $dotest/end`"
msgnum="`cat $dotest/msgnum`"
@@ -181,10 +178,7 @@ do
exit
;;
--abort)
- if test -d "$GIT_DIR/rr-cache"
- then
- git rerere clear
- fi
+ git rerere clear
if test -d "$dotest"
then
rm -r "$dotest"
diff --git a/git-send-email.perl b/git-send-email.perl
index 87f59fa313..89f7c36ee5 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -254,6 +254,8 @@ if (@alias_files and $aliasfiletype and defined $parse_alias{$aliasfiletype}) {
}
}
+($from) = expand_aliases($from) if defined $from;
+
my $prompting = 0;
if (!defined $from) {
$from = $author || $committer;
diff --git a/git-stash.sh b/git-stash.sh
index f01494dc1b..7b1638c68c 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -3,6 +3,7 @@
USAGE='[ | list | show | apply | clear]'
+SUBDIRECTORY_OK=Yes
. git-sh-setup
require_work_tree
diff --git a/t/t4116-apply-reverse.sh b/t/t4116-apply-reverse.sh
index a7f5905f1e..9ae2b3a8ef 100755
--- a/t/t4116-apply-reverse.sh
+++ b/t/t4116-apply-reverse.sh
@@ -82,4 +82,10 @@ test_expect_success 'apply in reverse without postimage' '
)
'
+test_expect_success 'reversing a whitespace introduction' '
+ sed "s/a/a /" < file1 > file1.new &&
+ mv file1.new file1 &&
+ git diff | git apply --reverse --whitespace=error
+'
+
test_done
diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh
index 71d364ab79..6f55ba03bd 100755
--- a/t/t4200-rerere.sh
+++ b/t/t4200-rerere.sh
@@ -39,15 +39,32 @@ sed -e 's/To die, t/To die! T/' > a1
echo "* END *" >>a1
git commit -q -a -m second
-# activate rerere
-mkdir .git/rr-cache
+test_expect_success 'nothing recorded without rerere' '
+ (rm -rf .git/rr-cache; git config rerere.enabled false) &&
+ ! git merge first &&
+ ! test -d .git/rr-cache
+'
-test_expect_failure 'conflicting merge' 'git pull . first'
+# activate rerere, old style
+test_expect_success 'conflicting merge' '
+ git reset --hard &&
+ mkdir .git/rr-cache &&
+ git config --unset rerere.enabled &&
+ ! git merge first
+'
sha1=$(sed -e 's/ .*//' .git/rr-cache/MERGE_RR)
rr=.git/rr-cache/$sha1
test_expect_success 'recorded preimage' "grep ======= $rr/preimage"
+test_expect_success 'rerere.enabled works, too' '
+ rm -rf .git/rr-cache &&
+ git config rerere.enabled true &&
+ git reset --hard &&
+ ! git merge first &&
+ grep ======= $rr/preimage
+'
+
test_expect_success 'no postimage or thisimage yet' \
"test ! -f $rr/postimage -a ! -f $rr/thisimage"