From 446247db78a733f44d2470afb1f1983d28058159 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 23 Aug 2008 12:56:57 -0700 Subject: merge: fix numerus bugs around "trivial merge" area The "trivial merge" codepath wants to optimize itself by making an internal call to the read-tree machinery, but it does not read the index before doing so, and the codepath is never exercised. Incidentally, this failure to read the index upfront means that the safety to refuse doing anything when the index is unmerged does not kick in, either. These two problem are fixed by using read_cache_unmerged() that does read the index before checking if it is unmerged at the beginning of cmd_merge(). The primary logic of the merge, however, assumes that the process never reads the index in-core, and the call to write_cache_as_tree() it makes from write_tree_trivial() will always read from the on-disk index that is prepared the strategy back-ends. This assumption is now broken by the above fix. To fix this issue, we now call discard_cache() before calling write_tree_trivial() when it wants to write the on-disk index as a tree. When multiple strategies are tried, their results are evaluated by reading the resulting index and inspecting it. The codepath needs to make a call to read_cache() for each successful strategy, and for that to work, they need to discard_cache() the one read by the previous round. Also the "trivial merge" forgot that the current commit is one of the parents of the resulting commit. Signed-off-by: Junio C Hamano diff --git a/builtin-merge.c b/builtin-merge.c index a201c66..b280444 100644 --- a/builtin-merge.c +++ b/builtin-merge.c @@ -564,8 +564,6 @@ static int checkout_fast_forward(unsigned char *head, unsigned char *remote) struct dir_struct dir; struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file)); - if (read_cache_unmerged()) - die("you need to resolve your current index first"); refresh_cache(REFRESH_QUIET); fd = hold_locked_index(lock_file, 1); @@ -651,13 +649,15 @@ static void add_strategies(const char *string, unsigned attr) static int merge_trivial(void) { unsigned char result_tree[20], result_commit[20]; - struct commit_list parent; + struct commit_list *parent = xmalloc(sizeof(struct commit_list *)); write_tree_trivial(result_tree); printf("Wonderful.\n"); - parent.item = remoteheads->item; - parent.next = NULL; - commit_tree(merge_msg.buf, result_tree, &parent, result_commit); + parent->item = lookup_commit(head); + parent->next = xmalloc(sizeof(struct commit_list *)); + parent->next->item = remoteheads->item; + parent->next->next = NULL; + commit_tree(merge_msg.buf, result_tree, parent, result_commit); finish(result_commit, "In-index merge"); drop_save(); return 0; @@ -743,6 +743,7 @@ static int evaluate_result(void) int cnt = 0; struct rev_info rev; + discard_cache(); if (read_cache() < 0) die("failed to read the cache"); @@ -776,7 +777,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) struct commit_list **remotes = &remoteheads; setup_work_tree(); - if (unmerged_cache()) + if (read_cache_unmerged()) die("You are in the middle of a conflicted merge."); /* @@ -1073,6 +1074,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) } /* Automerge succeeded. */ + discard_cache(); write_tree_trivial(result_tree); automerge_was_ok = 1; break; diff --git a/t/t3030-merge-recursive.sh b/t/t3030-merge-recursive.sh index aff3603..f288015 100755 --- a/t/t3030-merge-recursive.sh +++ b/t/t3030-merge-recursive.sh @@ -269,6 +269,17 @@ test_expect_success 'merge-recursive result' ' ' +test_expect_success 'fail if the index has unresolved entries' ' + + rm -fr [abcd] && + git checkout -f "$c1" && + + test_must_fail git merge "$c5" && + test_must_fail git merge "$c5" 2> out && + grep "You are in the middle of a conflicted merge" out + +' + test_expect_success 'merge-recursive remove conflict' ' rm -fr [abcd] && diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh index fee8fb7..dbc90bc 100755 --- a/t/t7600-merge.sh +++ b/t/t7600-merge.sh @@ -498,4 +498,13 @@ test_expect_success 'merge fast-forward in a dirty tree' ' test_debug 'gitk --all' +test_expect_success 'in-index merge' ' + git reset --hard c0 && + git merge --no-ff -s resolve c1 > out && + grep "Wonderful." out && + verify_parents $c0 $c1 +' + +test_debug 'gitk --all' + test_done diff --git a/t/t7605-merge-resolve.sh b/t/t7605-merge-resolve.sh index ee21a10..f1f86dd 100755 --- a/t/t7605-merge-resolve.sh +++ b/t/t7605-merge-resolve.sh @@ -36,7 +36,9 @@ test_expect_success 'merge c1 to c2' ' git diff --exit-code && test -f c0.c && test -f c1.c && - test -f c2.c + test -f c2.c && + test 3 = $(git ls-tree -r HEAD | wc -l) && + test 3 = $(git ls-files | wc -l) ' test_expect_success 'merge c2 to c3 (fails)' ' -- cgit v0.10.2-6-g49f6 From 7d770163271db1ec3608d3b2b77e306346e24a4a Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 24 Aug 2008 00:07:55 +0200 Subject: Makefile: enable SNPRINTF_RETURNS_BOGUS for HP-UX In 81cc66a, customization has been added to Makefile for supporting HP-UX, but git commit is still problematic. This should fix the issue. Signed-off-by: Miklos Vajna Acked-by: Robert Schiele Signed-off-by: Junio C Hamano diff --git a/Makefile b/Makefile index 53ab4b5..2cef018 100644 --- a/Makefile +++ b/Makefile @@ -727,6 +727,7 @@ ifeq ($(uname_S),HP-UX) NO_UNSETENV = YesPlease NO_HSTRERROR = YesPlease NO_SYS_SELECT_H = YesPlease + SNPRINTF_RETURNS_BOGUS = YesPlease endif ifneq (,$(findstring MINGW,$(uname_S))) NO_MMAP = YesPlease -- cgit v0.10.2-6-g49f6 From 5e568f9e3027797842807213ce590140c9daf9ce Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Sat, 23 Aug 2008 23:21:21 +0400 Subject: Respect core.autocrlf in combined diff Fix git-diff to make it produce useful 3-way diffs for merge conflicts in repositories with autocrlf enabled. Otherwise it always reports that the whole file was changed, because it uses the contents from the working tree without necessary conversion. Signed-off-by: Alexander Gavrilov Signed-off-by: Junio C Hamano diff --git a/combine-diff.c b/combine-diff.c index 9f80a1c..4dfc330 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -727,6 +727,18 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent, die("early EOF '%s'", elem->path); result[len] = 0; + + /* If not a fake symlink, apply filters, e.g. autocrlf */ + if (is_file) { + struct strbuf buf; + + strbuf_init(&buf, 0); + if (convert_to_git(elem->path, result, len, &buf, safe_crlf)) { + free(result); + result = strbuf_detach(&buf, &len); + result_size = len; + } + } } else { deleted_file: diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh index ec98509..b1cbd36 100755 --- a/t/t4015-diff-whitespace.sh +++ b/t/t4015-diff-whitespace.sh @@ -352,4 +352,20 @@ test_expect_success 'checkdiff allows new blank lines' ' git diff --check ' +test_expect_success 'combined diff with autocrlf conversion' ' + + git reset --hard && + echo >x hello && + git commit -m "one side" x && + git checkout HEAD^ && + echo >x goodbye && + git commit -m "the other side" x && + git config core.autocrlf true && + test_must_fail git merge master && + + git diff | sed -e "1,/^@@@/d" >actual && + ! grep "^-" actual + +' + test_done -- cgit v0.10.2-6-g49f6 From f5f7e4a18cf656747be8f8447ca304ddf716c742 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Sun, 24 Aug 2008 16:12:23 +0200 Subject: Clean up the git-p4 documentation This patch massages the documentation a bit for improved readability and cleans it up from outdated options/commands. Signed-off-by: Simon Hausmann Signed-off-by: Junio C Hamano diff --git a/contrib/fast-import/git-p4.txt b/contrib/fast-import/git-p4.txt index ac551d4..49b3359 100644 --- a/contrib/fast-import/git-p4.txt +++ b/contrib/fast-import/git-p4.txt @@ -3,14 +3,16 @@ git-p4 - Perforce <-> Git converter using git-fast-import Usage ===== -git-p4 supports two main modes: Importing from Perforce to a Git repository is -done using "git-p4 sync" or "git-p4 rebase". Submitting changes from Git back -to Perforce is done using "git-p4 submit". +git-p4 can be used in two different ways: + +1) To import changes from Perforce to a Git repository, using "git-p4 sync". + +2) To submit changes from Git back to Perforce, using "git-p4 submit". Importing ========= -You can simply start with +Simply start with git-p4 clone //depot/path/project @@ -18,11 +20,18 @@ or git-p4 clone //depot/path/project myproject -This will create an empty git repository in a subdirectory called "project" (or -"myproject" with the second command), import the head revision from the -specified perforce path into a git "p4" branch (remotes/p4 actually), create a -master branch off it and check it out. If you want the entire history (not just -the head revision) then you can simply append a "@all" to the depot path: +This will: + +1) Create an empty git repository in a subdirectory called "project" (or +"myproject" with the second command) + +2) Import the head revision from the given Perforce path into a git branch +called "p4" (remotes/p4 actually) + +3) Create a master branch based on it and check it out. + +If you want the entire history (not just the head revision) then you can simply +append a "@all" to the depot path: git-p4 clone //depot/project/main@all myproject @@ -37,31 +46,40 @@ If you want more control you can also use the git-p4 sync command directly: This will import the current head revision of the specified depot path into a "remotes/p4/master" branch of your git repository. You can use the ---branch=mybranch option to use a different branch. +--branch=mybranch option to import into a different branch. -If you want to import the entire history of a given depot path just use +If you want to import the entire history of a given depot path simply use: git-p4 sync //path/in/depot@all + +Note: + To achieve optimal compression you may want to run 'git repack -a -d -f' after a big import. This may take a while. -Support for Perforce integrations is still work in progress. Don't bother -trying it unless you want to hack on it :) - Incremental Imports =================== -After an initial import you can easily synchronize your git repository with -newer changes from the Perforce depot by just calling +After an initial import you can continue to synchronize your git repository +with newer changes from the Perforce depot by just calling git-p4 sync in your git repository. By default the "remotes/p4/master" branch is updated. -It is recommended to run 'git repack -a -d -f' from time to time when using -incremental imports to optimally combine the individual git packs that each -incremental import creates through the use of git-fast-import. +Advanced Setup +============== + +Suppose you have a periodically updated git repository somewhere, containing a +complete import of a Perforce project. This repository can be cloned and used +with git-p4. When updating the cloned repository with the "sync" command, +git-p4 will try to fetch changes from the original repository first. The git +protocol used with this is usually faster than importing from Perforce +directly. + +This behaviour can be disabled by setting the "git-p4.syncFromOrigin" git +configuration variable to "false". Updating ======== @@ -79,7 +97,7 @@ Submitting ========== git-p4 has support for submitting changes from a git repository back to the -Perforce depot. This requires a Perforce checkout separate to your git +Perforce depot. This requires a Perforce checkout separate from your git repository. To submit all changes that are in the current git branch but not in the "p4" branch (or "origin" if "p4" doesn't exist) simply call @@ -97,17 +115,6 @@ continue importing the remaining changes with git-p4 submit --continue -After submitting you should sync your perforce import branch ("p4" or "origin") -from Perforce using git-p4's sync command. - -If you have changes in your working directory that you haven't committed into -git yet but that you want to commit to Perforce directly ("quick fixes") then -you do not have to go through the intermediate step of creating a git commit -first but you can just call - - git-p4 submit --direct - - Example ======= -- cgit v0.10.2-6-g49f6 From 32818085ee88dd98c48a0838fba3c4673d5e819c Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Sun, 24 Aug 2008 00:38:06 -0500 Subject: Documentation: clarify pager. configuration It was not obvious from the text that pager. is a boolean setting. While we're changing the description, make some other improvements: lest we forget and fret, clarify that -p and pager. do not kick in when stdout is not a tty; point to related core.pager and GIT_PAGER settings; use renamed --paginate option. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano diff --git a/Documentation/config.txt b/Documentation/config.txt index 676c39b..1679582 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -979,9 +979,11 @@ pack.packSizeLimit:: linkgit:git-repack[1]. pager.:: - Allows to set your own pager preferences for each command, overriding - the default. If `\--pager` or `\--no-pager` is specified on the command - line, it takes precedence over this option. + Allows turning on or off pagination of the output of a + particular git subcommand when writing to a tty. If + `\--paginate` or `\--no-pager` is specified on the command line, + it takes precedence over this option. To disable pagination for + all commands, set `core.pager` or 'GIT_PAGER' to "`cat`". pull.octopus:: The default merge strategy to use when pulling multiple branches -- cgit v0.10.2-6-g49f6 From ab54cd6c4d54b7d9bf6dccfa7ea54f209ea76601 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Sun, 24 Aug 2008 00:28:32 -0500 Subject: Documentation: clarify pager configuration The unwary user may not know how to disable the -FRSX options. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano diff --git a/Documentation/config.txt b/Documentation/config.txt index 1679582..81f9815 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -358,8 +358,13 @@ core.editor:: `EDITOR` environment variables and then finally `vi`. core.pager:: - The command that git will use to paginate output. Can be overridden - with the `GIT_PAGER` environment variable. + The command that git will use to paginate output. Can + be overridden with the `GIT_PAGER` environment + variable. Note that git sets the `LESS` environment + variable to `FRSX` if it is unset when it runs the + pager. One can change these settings by setting the + `LESS` variable to some other value or by giving the + `core.pager` option a value such as "`less -+FRSX`". core.whitespace:: A comma separated list of common whitespace problems to diff --git a/Documentation/git.txt b/Documentation/git.txt index 1bc295d..363a785 100644 --- a/Documentation/git.txt +++ b/Documentation/git.txt @@ -497,7 +497,8 @@ other 'GIT_PAGER':: This environment variable overrides `$PAGER`. If it is set to an empty string or to the value "cat", git will not launch - a pager. + a pager. See also the `core.pager` option in + linkgit:git-config[1]. 'GIT_SSH':: If this environment variable is set then 'git-fetch' -- cgit v0.10.2-6-g49f6 From 5760a6b094736e6f59eb32c7abb4cdbb7fca1627 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 24 Aug 2008 14:47:24 -0700 Subject: GIT 1.6.0.1 Signed-off-by: Junio C Hamano diff --git a/Documentation/RelNotes-1.6.0.1.txt b/Documentation/RelNotes-1.6.0.1.txt index bac117e..49d7a1c 100644 --- a/Documentation/RelNotes-1.6.0.1.txt +++ b/Documentation/RelNotes-1.6.0.1.txt @@ -4,6 +4,9 @@ GIT v1.6.0.1 Release Notes Fixes since v1.6.0 ------------------ +* "git diff --cc" did not honor content mangling specified by + gitattributes and core.autocrlf when reading from the work tree. + * "git diff --check" incorrectly detected new trailing blank lines when whitespace check was in effect. @@ -13,6 +16,8 @@ Fixes since v1.6.0 * "git format-patch" peeked before the beginning of a string when "format.headers" variable is empty (a misconfiguration). +* "git help help" did not work correctly. + * "git mailinfo" (hence "git am") was unhappy when MIME multipart message contained garbage after the finishing boundary. @@ -22,10 +27,10 @@ Fixes since v1.6.0 * "git merge" did not refresh the index correctly when a merge resulted in a fast-forward. -Contains other various documentation fixes. +* "git merge" did not resolve a truly trivial merges that can be done + without content level merges. --- -exec >/var/tmp/1 -O=v1.6.0-14-g3a634dc -echo O=$(git describe maint) -git shortlog --no-merges $O..maint +* "git svn dcommit" to a repository with URL that has embedded usernames + did not work correctly. + +Contains other various documentation fixes. -- cgit v0.10.2-6-g49f6