From 59eb68aa2b4e52aa1d098e0d76c5130864ceff2e Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 21 Jul 2008 12:14:42 -0700 Subject: [PATCH 01/14] Update my e-mail address The old cox.net address is still getting mails from gitters. Signed-off-by: Junio C Hamano --- Documentation/git-am.txt | 2 +- Documentation/git-blame.txt | 2 +- Documentation/git-branch.txt | 2 +- Documentation/git-check-attr.txt | 2 +- Documentation/git-cherry-pick.txt | 2 +- Documentation/git-cherry.txt | 2 +- Documentation/git-commit.txt | 2 +- Documentation/git-count-objects.txt | 2 +- Documentation/git-describe.txt | 2 +- Documentation/git-fetch.txt | 2 +- Documentation/git-fmt-merge-msg.txt | 2 +- Documentation/git-format-patch.txt | 2 +- Documentation/git-hash-object.txt | 2 +- Documentation/git-ls-remote.txt | 2 +- Documentation/git-ls-tree.txt | 2 +- Documentation/git-mailinfo.txt | 2 +- Documentation/git-mailsplit.txt | 2 +- Documentation/git-merge-one-file.txt | 2 +- Documentation/git-merge.txt | 2 +- Documentation/git-mktree.txt | 2 +- Documentation/git-peek-remote.txt | 2 +- Documentation/git-pull.txt | 2 +- Documentation/git-push.txt | 2 +- Documentation/git-rebase.txt | 2 +- Documentation/git-reflog.txt | 2 +- Documentation/git-request-pull.txt | 2 +- Documentation/git-rerere.txt | 2 +- Documentation/git-reset.txt | 2 +- Documentation/git-rev-parse.txt | 2 +- Documentation/git-revert.txt | 2 +- Documentation/git-show-branch.txt | 2 +- Documentation/git-show.txt | 2 +- Documentation/git-status.txt | 2 +- Documentation/git-symbolic-ref.txt | 2 +- Documentation/git-tag.txt | 2 +- Documentation/git-update-server-info.txt | 2 +- Documentation/git-verify-pack.txt | 2 +- Documentation/git-whatchanged.txt | 2 +- Documentation/howto/rebase-from-internal-branch.txt | 2 +- Documentation/howto/rebuild-from-update-hook.txt | 2 +- Documentation/howto/revert-branch-rebase.txt | 2 +- Documentation/howto/separating-topic-branches.txt | 2 +- Documentation/howto/update-hook-example.txt | 2 +- 43 files changed, 43 insertions(+), 43 deletions(-) diff --git a/Documentation/git-am.txt b/Documentation/git-am.txt index e010a16493..719e924980 100644 --- a/Documentation/git-am.txt +++ b/Documentation/git-am.txt @@ -162,7 +162,7 @@ linkgit:git-apply[1]. Author ------ -Written by Junio C Hamano +Written by Junio C Hamano Documentation -------------- diff --git a/Documentation/git-blame.txt b/Documentation/git-blame.txt index 34b24a3cad..fba374d652 100644 --- a/Documentation/git-blame.txt +++ b/Documentation/git-blame.txt @@ -190,7 +190,7 @@ linkgit:git-annotate[1] AUTHOR ------ -Written by Junio C Hamano +Written by Junio C Hamano GIT --- diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt index fc5a4a602f..6103d62fe3 100644 --- a/Documentation/git-branch.txt +++ b/Documentation/git-branch.txt @@ -205,7 +205,7 @@ but different purposes: Author ------ -Written by Linus Torvalds and Junio C Hamano +Written by Linus Torvalds and Junio C Hamano Documentation -------------- diff --git a/Documentation/git-check-attr.txt b/Documentation/git-check-attr.txt index abe1f1b7dd..2b821f2a1d 100644 --- a/Documentation/git-check-attr.txt +++ b/Documentation/git-check-attr.txt @@ -30,7 +30,7 @@ linkgit:gitattributes[5]. Author ------ -Written by Junio C Hamano +Written by Junio C Hamano Documentation -------------- diff --git a/Documentation/git-cherry-pick.txt b/Documentation/git-cherry-pick.txt index 50fb3d5d54..837fb08b79 100644 --- a/Documentation/git-cherry-pick.txt +++ b/Documentation/git-cherry-pick.txt @@ -74,7 +74,7 @@ effect to your index in a row. Author ------ -Written by Junio C Hamano +Written by Junio C Hamano Documentation -------------- diff --git a/Documentation/git-cherry.txt b/Documentation/git-cherry.txt index d761a73423..74d14c4e7f 100644 --- a/Documentation/git-cherry.txt +++ b/Documentation/git-cherry.txt @@ -64,7 +64,7 @@ linkgit:git-patch-id[1] Author ------ -Written by Junio C Hamano +Written by Junio C Hamano Documentation -------------- diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt index 01bd2d6b77..0e25bb8627 100644 --- a/Documentation/git-commit.txt +++ b/Documentation/git-commit.txt @@ -331,7 +331,7 @@ linkgit:git-commit-tree[1] Author ------ Written by Linus Torvalds and -Junio C Hamano +Junio C Hamano GIT diff --git a/Documentation/git-count-objects.txt b/Documentation/git-count-objects.txt index c069cc8b04..75a8da1ca9 100644 --- a/Documentation/git-count-objects.txt +++ b/Documentation/git-count-objects.txt @@ -27,7 +27,7 @@ OPTIONS Author ------ -Written by Junio C Hamano +Written by Junio C Hamano Documentation -------------- diff --git a/Documentation/git-describe.txt b/Documentation/git-describe.txt index 44b166888a..7fdda04bae 100644 --- a/Documentation/git-describe.txt +++ b/Documentation/git-describe.txt @@ -136,7 +136,7 @@ will be the smallest number of commits possible. Author ------ Written by Linus Torvalds , but somewhat -butchered by Junio C Hamano . Later significantly +butchered by Junio C Hamano . Later significantly updated by Shawn Pearce . Documentation diff --git a/Documentation/git-fetch.txt b/Documentation/git-fetch.txt index 9e048a8a28..d3164c5c88 100644 --- a/Documentation/git-fetch.txt +++ b/Documentation/git-fetch.txt @@ -45,7 +45,7 @@ linkgit:git-pull[1] Author ------ Written by Linus Torvalds and -Junio C Hamano +Junio C Hamano Documentation ------------- diff --git a/Documentation/git-fmt-merge-msg.txt b/Documentation/git-fmt-merge-msg.txt index 885edf005a..1c24796d66 100644 --- a/Documentation/git-fmt-merge-msg.txt +++ b/Documentation/git-fmt-merge-msg.txt @@ -61,7 +61,7 @@ linkgit:git-merge[1] Author ------ -Written by Junio C Hamano +Written by Junio C Hamano Documentation -------------- diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt index 7c2ff3eb2d..010d9e4322 100644 --- a/Documentation/git-format-patch.txt +++ b/Documentation/git-format-patch.txt @@ -235,7 +235,7 @@ linkgit:git-am[1], linkgit:git-send-email[1] Author ------ -Written by Junio C Hamano +Written by Junio C Hamano Documentation -------------- diff --git a/Documentation/git-hash-object.txt b/Documentation/git-hash-object.txt index 9e654fc41c..ac928e198e 100644 --- a/Documentation/git-hash-object.txt +++ b/Documentation/git-hash-object.txt @@ -37,7 +37,7 @@ OPTIONS Author ------ -Written by Junio C Hamano +Written by Junio C Hamano Documentation -------------- diff --git a/Documentation/git-ls-remote.txt b/Documentation/git-ls-remote.txt index 4f252441ed..abe7bf9ff9 100644 --- a/Documentation/git-ls-remote.txt +++ b/Documentation/git-ls-remote.txt @@ -69,7 +69,7 @@ EXAMPLES Author ------ -Written by Junio C Hamano +Written by Junio C Hamano GIT --- diff --git a/Documentation/git-ls-tree.txt b/Documentation/git-ls-tree.txt index 1cdec222a1..d7e73f568d 100644 --- a/Documentation/git-ls-tree.txt +++ b/Documentation/git-ls-tree.txt @@ -81,7 +81,7 @@ with minimum width of 7 characters. Object size is given only for blobs Author ------ Written by Petr Baudis -Completely rewritten from scratch by Junio C Hamano , +Completely rewritten from scratch by Junio C Hamano , another major rewrite by Linus Torvalds Documentation diff --git a/Documentation/git-mailinfo.txt b/Documentation/git-mailinfo.txt index 316bcc6796..31eccea5bc 100644 --- a/Documentation/git-mailinfo.txt +++ b/Documentation/git-mailinfo.txt @@ -60,7 +60,7 @@ conversion, even with this flag. Author ------ Written by Linus Torvalds and -Junio C Hamano +Junio C Hamano Documentation diff --git a/Documentation/git-mailsplit.txt b/Documentation/git-mailsplit.txt index acd712b1cd..5cc94ec53d 100644 --- a/Documentation/git-mailsplit.txt +++ b/Documentation/git-mailsplit.txt @@ -46,7 +46,7 @@ OPTIONS Author ------ Written by Linus Torvalds -and Junio C Hamano +and Junio C Hamano Documentation diff --git a/Documentation/git-merge-one-file.txt b/Documentation/git-merge-one-file.txt index 1dd134538d..dc8a96adb0 100644 --- a/Documentation/git-merge-one-file.txt +++ b/Documentation/git-merge-one-file.txt @@ -18,7 +18,7 @@ to resolve a merge after the trivial merge done with 'git-read-tree -m'. Author ------ Written by Linus Torvalds , -Junio C Hamano and Petr Baudis . +Junio C Hamano and Petr Baudis . Documentation -------------- diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt index a7487d3dfd..2db8880989 100644 --- a/Documentation/git-merge.txt +++ b/Documentation/git-merge.txt @@ -145,7 +145,7 @@ linkgit:git-mergetool[1] Author ------ -Written by Junio C Hamano +Written by Junio C Hamano Documentation diff --git a/Documentation/git-mktree.txt b/Documentation/git-mktree.txt index 0be32e2612..af19f06ed7 100644 --- a/Documentation/git-mktree.txt +++ b/Documentation/git-mktree.txt @@ -23,7 +23,7 @@ OPTIONS Author ------ -Written by Junio C Hamano +Written by Junio C Hamano Documentation -------------- diff --git a/Documentation/git-peek-remote.txt b/Documentation/git-peek-remote.txt index 79c03ee7f7..8282a5e82b 100644 --- a/Documentation/git-peek-remote.txt +++ b/Documentation/git-peek-remote.txt @@ -39,7 +39,7 @@ OPTIONS Author ------ -Written by Junio C Hamano +Written by Junio C Hamano Documentation -------------- diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt index 092d1b8a3e..7578623edb 100644 --- a/Documentation/git-pull.txt +++ b/Documentation/git-pull.txt @@ -193,7 +193,7 @@ linkgit:git-fetch[1], linkgit:git-merge[1], linkgit:git-config[1] Author ------ Written by Linus Torvalds -and Junio C Hamano +and Junio C Hamano Documentation -------------- diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt index c44dce374a..94d07ab812 100644 --- a/Documentation/git-push.txt +++ b/Documentation/git-push.txt @@ -195,7 +195,7 @@ git push origin master:refs/heads/experimental:: Author ------ -Written by Junio C Hamano , later rewritten in C +Written by Junio C Hamano , later rewritten in C by Linus Torvalds Documentation diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt index 51afc87e17..58a5c746ba 100644 --- a/Documentation/git-rebase.txt +++ b/Documentation/git-rebase.txt @@ -398,7 +398,7 @@ after each commit, test, and amend the commit if fixes are necessary. Authors ------ -Written by Junio C Hamano and +Written by Junio C Hamano and Johannes E. Schindelin Documentation diff --git a/Documentation/git-reflog.txt b/Documentation/git-reflog.txt index 146d7f545c..d99236e14d 100644 --- a/Documentation/git-reflog.txt +++ b/Documentation/git-reflog.txt @@ -94,7 +94,7 @@ them. Author ------ -Written by Junio C Hamano +Written by Junio C Hamano Documentation -------------- diff --git a/Documentation/git-request-pull.txt b/Documentation/git-request-pull.txt index ca6843032a..19335fddae 100644 --- a/Documentation/git-request-pull.txt +++ b/Documentation/git-request-pull.txt @@ -28,7 +28,7 @@ OPTIONS Author ------ -Written by Ryan Anderson and Junio C Hamano +Written by Ryan Anderson and Junio C Hamano Documentation -------------- diff --git a/Documentation/git-rerere.txt b/Documentation/git-rerere.txt index 678bfd3cde..beebd5301f 100644 --- a/Documentation/git-rerere.txt +++ b/Documentation/git-rerere.txt @@ -204,7 +204,7 @@ conflict. Author ------ -Written by Junio C Hamano +Written by Junio C Hamano GIT --- diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt index c8d175768c..6abaeac28c 100644 --- a/Documentation/git-reset.txt +++ b/Documentation/git-reset.txt @@ -195,7 +195,7 @@ $ git add frotz.c <3> Author ------ -Written by Junio C Hamano and Linus Torvalds +Written by Junio C Hamano and Linus Torvalds Documentation -------------- diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt index 088f971b79..5c936693d3 100644 --- a/Documentation/git-rev-parse.txt +++ b/Documentation/git-rev-parse.txt @@ -426,7 +426,7 @@ but if $REV is empty, the commit object name from master will be printed. Author ------ Written by Linus Torvalds . -Junio C Hamano and Pierre Habouzit +Junio C Hamano and Pierre Habouzit Documentation -------------- diff --git a/Documentation/git-revert.txt b/Documentation/git-revert.txt index 271850f511..98cfa3c0d0 100644 --- a/Documentation/git-revert.txt +++ b/Documentation/git-revert.txt @@ -61,7 +61,7 @@ effect to your index in a row. Author ------ -Written by Junio C Hamano +Written by Junio C Hamano Documentation -------------- diff --git a/Documentation/git-show-branch.txt b/Documentation/git-show-branch.txt index 14e10362b1..d3f258869f 100644 --- a/Documentation/git-show-branch.txt +++ b/Documentation/git-show-branch.txt @@ -182,7 +182,7 @@ topologically related with each other. Author ------ -Written by Junio C Hamano +Written by Junio C Hamano Documentation diff --git a/Documentation/git-show.txt b/Documentation/git-show.txt index e0b52bcb37..1642cfd823 100644 --- a/Documentation/git-show.txt +++ b/Documentation/git-show.txt @@ -71,7 +71,7 @@ include::i18n.txt[] Author ------ Written by Linus Torvalds and -Junio C Hamano . Significantly enhanced by +Junio C Hamano . Significantly enhanced by Johannes Schindelin . diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt index 57b7498239..84f60f3407 100644 --- a/Documentation/git-status.txt +++ b/Documentation/git-status.txt @@ -64,7 +64,7 @@ linkgit:gitignore[5] Author ------ Written by Linus Torvalds and -Junio C Hamano . +Junio C Hamano . Documentation -------------- diff --git a/Documentation/git-symbolic-ref.txt b/Documentation/git-symbolic-ref.txt index 6266e6f658..210fde03a1 100644 --- a/Documentation/git-symbolic-ref.txt +++ b/Documentation/git-symbolic-ref.txt @@ -55,7 +55,7 @@ name is not a symbolic ref, or 128 if another error occurs. Author ------ -Written by Junio C Hamano +Written by Junio C Hamano GIT --- diff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt index b605e6caa2..b8dc88fa38 100644 --- a/Documentation/git-tag.txt +++ b/Documentation/git-tag.txt @@ -247,7 +247,7 @@ $ GIT_COMMITTER_DATE="2006-10-02 10:31" git tag -s v1.0.1 Author ------ Written by Linus Torvalds , -Junio C Hamano and Chris Wright . +Junio C Hamano and Chris Wright . Documentation -------------- diff --git a/Documentation/git-update-server-info.txt b/Documentation/git-update-server-info.txt index bc1207a317..35d27b0c7f 100644 --- a/Documentation/git-update-server-info.txt +++ b/Documentation/git-update-server-info.txt @@ -47,7 +47,7 @@ info/refs file unless `--force` flag is given. Author ------ -Written by Junio C Hamano +Written by Junio C Hamano Documentation -------------- diff --git a/Documentation/git-verify-pack.txt b/Documentation/git-verify-pack.txt index 53a9ce3085..c8611632d1 100644 --- a/Documentation/git-verify-pack.txt +++ b/Documentation/git-verify-pack.txt @@ -42,7 +42,7 @@ for objects that are deltified. Author ------ -Written by Junio C Hamano +Written by Junio C Hamano Documentation -------------- diff --git a/Documentation/git-whatchanged.txt b/Documentation/git-whatchanged.txt index d7fad15329..cadfbd9040 100644 --- a/Documentation/git-whatchanged.txt +++ b/Documentation/git-whatchanged.txt @@ -67,7 +67,7 @@ git whatchanged --since="2 weeks ago" \-- gitk:: Author ------ Written by Linus Torvalds and -Junio C Hamano +Junio C Hamano Documentation diff --git a/Documentation/howto/rebase-from-internal-branch.txt b/Documentation/howto/rebase-from-internal-branch.txt index 7a76045eb7..d214d4bf9d 100644 --- a/Documentation/howto/rebase-from-internal-branch.txt +++ b/Documentation/howto/rebase-from-internal-branch.txt @@ -1,4 +1,4 @@ -From: Junio C Hamano +From: Junio C Hamano To: git@vger.kernel.org Cc: Petr Baudis , Linus Torvalds Subject: Re: sending changesets from the middle of a git tree diff --git a/Documentation/howto/rebuild-from-update-hook.txt b/Documentation/howto/rebuild-from-update-hook.txt index 8d55dfbfae..48c67568d3 100644 --- a/Documentation/howto/rebuild-from-update-hook.txt +++ b/Documentation/howto/rebuild-from-update-hook.txt @@ -1,6 +1,6 @@ Subject: [HOWTO] Using post-update hook Message-ID: <7vy86o6usx.fsf@assigned-by-dhcp.cox.net> -From: Junio C Hamano +From: Junio C Hamano Date: Fri, 26 Aug 2005 18:19:10 -0700 Abstract: In this how-to article, JC talks about how he uses the post-update hook to automate git documentation page diff --git a/Documentation/howto/revert-branch-rebase.txt b/Documentation/howto/revert-branch-rebase.txt index 865a666324..e70d8a31e7 100644 --- a/Documentation/howto/revert-branch-rebase.txt +++ b/Documentation/howto/revert-branch-rebase.txt @@ -1,4 +1,4 @@ -From: Junio C Hamano +From: Junio C Hamano To: git@vger.kernel.org Subject: [HOWTO] Reverting an existing commit Abstract: In this article, JC gives a small real-life example of using diff --git a/Documentation/howto/separating-topic-branches.txt b/Documentation/howto/separating-topic-branches.txt index 0d73b31224..6d3eb8ed00 100644 --- a/Documentation/howto/separating-topic-branches.txt +++ b/Documentation/howto/separating-topic-branches.txt @@ -1,4 +1,4 @@ -From: Junio C Hamano +From: Junio C Hamano Subject: Separating topic branches Abstract: In this article, JC describes how to separate topic branches. diff --git a/Documentation/howto/update-hook-example.txt b/Documentation/howto/update-hook-example.txt index 8b2ec502f4..697d918885 100644 --- a/Documentation/howto/update-hook-example.txt +++ b/Documentation/howto/update-hook-example.txt @@ -1,4 +1,4 @@ -From: Junio C Hamano and Carl Baldwin +From: Junio C Hamano and Carl Baldwin Subject: control access to branches. Date: Thu, 17 Nov 2005 23:55:32 -0800 Message-ID: <7vfypumlu3.fsf@assigned-by-dhcp.cox.net> From 51ef1daa4a0dfaa4d777b2fa949ba051cf800554 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 21 Jul 2008 12:51:02 +0200 Subject: [PATCH 02/14] Rename .git/rebase to .git/rebase-apply With git-am, it sounds awkward to have the patches in ".git/rebase/", but for technical reasons, we have to keep the same directory name for git-am and git-rebase. ".git/rebase-apply" seems to be a good compromise. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- Documentation/SubmittingPatches | 2 +- Documentation/git-am.txt | 4 +-- Documentation/git-rebase.txt | 4 +-- Documentation/user-manual.txt | 2 +- contrib/completion/git-completion.bash | 10 +++--- contrib/emacs/git.el | 8 ++--- git-am.sh | 2 +- git-quiltimport.sh | 2 +- git-rebase.sh | 48 ++++++++++++++------------ t/t3401-rebase-partial.sh | 2 +- t/t3407-rebase-abort.sh | 2 +- t/t4150-am.sh | 22 ++++++------ t/t9106-git-svn-commit-diff-clobber.sh | 4 ++- 13 files changed, 58 insertions(+), 54 deletions(-) diff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches index fdfa536441..841bead9db 100644 --- a/Documentation/SubmittingPatches +++ b/Documentation/SubmittingPatches @@ -301,7 +301,7 @@ If it does not apply correctly, there can be various reasons. patch appropriately. * Your MUA corrupted your patch; "am" would complain that - the patch does not apply. Look at .git/rebase/ subdirectory and + the patch does not apply. Look at .git/rebase-apply/ subdirectory and see what 'patch' file contains and check for the common corruption patterns mentioned above. diff --git a/Documentation/git-am.txt b/Documentation/git-am.txt index 719e924980..c45c53ec24 100644 --- a/Documentation/git-am.txt +++ b/Documentation/git-am.txt @@ -143,9 +143,9 @@ aborts in the middle,. You can recover from this in one of two ways: the index file to bring it in a state that the patch should have produced. Then run the command with '--resolved' option. -The command refuses to process new mailboxes while `.git/rebase` +The command refuses to process new mailboxes while `.git/rebase-apply` directory exists, so if you decide to start over from scratch, -run `rm -f -r .git/rebase` before running the command with mailbox +run `rm -f -r .git/rebase-apply` before running the command with mailbox names. Before any patches are applied, ORIG_HEAD is set to the tip of the diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt index 58a5c746ba..59c1b021a6 100644 --- a/Documentation/git-rebase.txt +++ b/Documentation/git-rebase.txt @@ -39,8 +39,8 @@ It is possible that a merge failure will prevent this process from being completely automatic. You will have to resolve any such merge failure and run `git rebase --continue`. Another option is to bypass the commit that caused the merge failure with `git rebase --skip`. To restore the -original and remove the .git/rebase working files, use the command -`git rebase --abort` instead. +original and remove the .git/rebase-apply working files, use the +command `git rebase --abort` instead. Assume the following history exists and the current branch is "topic": diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt index 8761ee7e7d..c5641af190 100644 --- a/Documentation/user-manual.txt +++ b/Documentation/user-manual.txt @@ -2431,7 +2431,7 @@ $ git rebase origin ------------------------------------------------- This will remove each of your commits from mywork, temporarily saving -them as patches (in a directory named ".git/rebase"), update mywork to +them as patches (in a directory named ".git/rebase-apply"), update mywork to point at the latest version of origin, then apply each of the saved patches to the new mywork. The result will look like: diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 29f6cd4e9e..2edb341b57 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -73,12 +73,12 @@ __git_ps1 () if [ -n "$g" ]; then local r local b - if [ -d "$g/rebase" ] + if [ -d "$g/rebase-apply" ] then - if test -f "$g/rebase/rebasing" + if test -f "$g/rebase-apply/rebasing" then r="|REBASE" - elif test -f "$g/rebase/applying" + elif test -f "$g/rebase-apply/applying" then r="|AM" else @@ -488,7 +488,7 @@ __git_whitespacelist="nowarn warn error error-all strip" _git_am () { local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)" - if [ -d "$dir"/rebase ]; then + if [ -d "$dir"/rebase-apply ]; then __gitcomp "--skip --resolved" return fi @@ -915,7 +915,7 @@ _git_push () _git_rebase () { local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)" - if [ -d "$dir"/rebase ] || [ -d "$dir"/rebase-merge ]; then + if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then __gitcomp "--continue --skip --abort" return fi diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el index 43b059bbaa..c1cf1cbcc0 100644 --- a/contrib/emacs/git.el +++ b/contrib/emacs/git.el @@ -1252,8 +1252,8 @@ Return the list of files that haven't been handled." "\n") (when subject (insert subject "\n\n")) (cond (msg (insert msg "\n")) - ((file-readable-p ".git/rebase/msg") - (insert-file-contents ".git/rebase/msg")) + ((file-readable-p ".git/rebase-apply/msg") + (insert-file-contents ".git/rebase-apply/msg")) ((file-readable-p ".git/MERGE_MSG") (insert-file-contents ".git/MERGE_MSG"))) ; delete empty lines at end @@ -1272,9 +1272,9 @@ Return the list of files that haven't been handled." (coding-system (git-get-commits-coding-system)) author-name author-email subject date) (when (eq 0 (buffer-size buffer)) - (when (file-readable-p ".git/rebase/info") + (when (file-readable-p ".git/rebase-apply/info") (with-temp-buffer - (insert-file-contents ".git/rebase/info") + (insert-file-contents ".git/rebase-apply/info") (goto-char (point-min)) (when (re-search-forward "^Author: \\(.*\\)\nEmail: \\(.*\\)$" nil t) (setq author-name (match-string 1)) diff --git a/git-am.sh b/git-am.sh index 60aaa4a583..9bf12feeb2 100755 --- a/git-am.sh +++ b/git-am.sh @@ -121,7 +121,7 @@ It does not apply to blobs recorded in its index." } prec=4 -dotest="$GIT_DIR/rebase" +dotest="$GIT_DIR/rebase-apply" sign= utf8=t keep= skip= interactive= resolved= binary= rebasing= abort= resolvemsg= resume= git_apply_opt= diff --git a/git-quiltimport.sh b/git-quiltimport.sh index c9aecfd913..cebaee1cc9 100755 --- a/git-quiltimport.sh +++ b/git-quiltimport.sh @@ -53,7 +53,7 @@ if ! [ -d "$QUILT_PATCHES" ] ; then fi # Temporary directories -tmp_dir="$GIT_DIR"/rebase +tmp_dir="$GIT_DIR"/rebase-apply tmp_msg="$tmp_dir/msg" tmp_patch="$tmp_dir/patch" tmp_info="$tmp_dir/info" diff --git a/git-rebase.sh b/git-rebase.sh index 6ef5754814..412e135c3a 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -14,8 +14,8 @@ It is possible that a merge failure will prevent this process from being completely automatic. You will have to resolve any such merge failure and run git rebase --continue. Another option is to bypass the commit that caused the merge failure with git rebase --skip. To restore the -original and remove the .git/rebase working files, use the command -git rebase --abort instead. +original and remove the .git/rebase-apply working files, use the +command git rebase --abort instead. Note that if is not specified on the command line, the currently checked out branch is used. @@ -150,7 +150,7 @@ while test $# != 0 do case "$1" in --continue) - test -d "$dotest" -o -d "$GIT_DIR"/rebase || + test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply || die "No rebase in progress?" git diff-files --quiet --ignore-submodules || { @@ -173,15 +173,15 @@ do finish_rb_merge exit fi - head_name=$(cat "$GIT_DIR"/rebase/head-name) && - onto=$(cat "$GIT_DIR"/rebase/onto) && - orig_head=$(cat "$GIT_DIR"/rebase/orig-head) && + head_name=$(cat "$GIT_DIR"/rebase-apply/head-name) && + onto=$(cat "$GIT_DIR"/rebase-apply/onto) && + orig_head=$(cat "$GIT_DIR"/rebase-apply/orig-head) && git am --resolved --3way --resolvemsg="$RESOLVEMSG" && move_to_original_branch exit ;; --skip) - test -d "$dotest" -o -d "$GIT_DIR"/rebase || + test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply || die "No rebase in progress?" git reset --hard HEAD || exit $? @@ -201,15 +201,15 @@ do finish_rb_merge exit fi - head_name=$(cat "$GIT_DIR"/rebase/head-name) && - onto=$(cat "$GIT_DIR"/rebase/onto) && - orig_head=$(cat "$GIT_DIR"/rebase/orig-head) && + head_name=$(cat "$GIT_DIR"/rebase-apply/head-name) && + onto=$(cat "$GIT_DIR"/rebase-apply/onto) && + orig_head=$(cat "$GIT_DIR"/rebase-apply/orig-head) && git am -3 --skip --resolvemsg="$RESOLVEMSG" && move_to_original_branch exit ;; --abort) - test -d "$dotest" -o -d "$GIT_DIR"/rebase || + test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply || die "No rebase in progress?" git rerere clear @@ -217,7 +217,7 @@ do then move_to_original_branch else - dotest="$GIT_DIR"/rebase + dotest="$GIT_DIR"/rebase-apply move_to_original_branch fi git reset --hard $(cat "$dotest/orig-head") @@ -265,18 +265,20 @@ do shift done -# Make sure we do not have $GIT_DIR/rebase +# Make sure we do not have $GIT_DIR/rebase-apply if test -z "$do_merge" then - if mkdir "$GIT_DIR"/rebase + if mkdir "$GIT_DIR"/rebase-apply then - rmdir "$GIT_DIR"/rebase + rmdir "$GIT_DIR"/rebase-apply else echo >&2 ' -It seems that I cannot create a '"$GIT_DIR"'/rebase directory, and I wonder if you -are in the middle of patch application or another rebase. If that is not -the case, please rm -fr '"$GIT_DIR"'/rebase and run me again. I am stopping in case -you still have something valuable there.' +It seems that I cannot create a '"$GIT_DIR"'/rebase-apply directory, +and I wonder if you are in the middle of patch application or another +rebase. If that is not the case, please + rm -fr '"$GIT_DIR"'/rebase-apply + and run me again. I am stopping in case you still have something +valuable there.' exit 1 fi else @@ -395,10 +397,10 @@ then git am $git_am_opt --rebasing --resolvemsg="$RESOLVEMSG" && move_to_original_branch ret=$? - test 0 != $ret -a -d "$GIT_DIR"/rebase && - echo $head_name > "$GIT_DIR"/rebase/head-name && - echo $onto > "$GIT_DIR"/rebase/onto && - echo $orig_head > "$GIT_DIR"/rebase/orig-head + test 0 != $ret -a -d "$GIT_DIR"/rebase-apply && + echo $head_name > "$GIT_DIR"/rebase-apply/head-name && + echo $onto > "$GIT_DIR"/rebase-apply/onto && + echo $orig_head > "$GIT_DIR"/rebase-apply/orig-head exit $ret fi diff --git a/t/t3401-rebase-partial.sh b/t/t3401-rebase-partial.sh index 36d9a2ae3a..166ddb1447 100755 --- a/t/t3401-rebase-partial.sh +++ b/t/t3401-rebase-partial.sh @@ -50,7 +50,7 @@ test_debug \ test_expect_success \ 'rebase topic branch against new master and check git-am did not get halted' \ - 'git-rebase master && test ! -d .git/rebase' + 'git-rebase master && test ! -d .git/rebase-apply' test_expect_success \ 'rebase --merge topic branch that was partially merged upstream' \ diff --git a/t/t3407-rebase-abort.sh b/t/t3407-rebase-abort.sh index 12c8804a03..4de550a632 100755 --- a/t/t3407-rebase-abort.sh +++ b/t/t3407-rebase-abort.sh @@ -74,7 +74,7 @@ testrebase() { ' } -testrebase "" .git/rebase +testrebase "" .git/rebase-apply testrebase " --merge" .git/rebase-merge test_done diff --git a/t/t4150-am.sh b/t/t4150-am.sh index 98ba020d89..6e6aaf5936 100755 --- a/t/t4150-am.sh +++ b/t/t4150-am.sh @@ -102,7 +102,7 @@ test_expect_success 'am applies patch correctly' ' git checkout first && test_tick && git am >file && git add file && git am --resolved && - ! test -d .git/rebase && + ! test -d .git/rebase-apply && test goodbye = "$(cat another)" ' test_expect_success 'am takes patches from a Pine mailbox' ' git checkout first && cat pine patch1 | git am && - ! test -d .git/rebase && + ! test -d .git/rebase-apply && test -z "$(git diff master^..HEAD)" ' test_expect_success 'am fails on mail without patch' ' test_must_fail git am >failmail && test_must_fail git am file && From c455c87c5cd42bbbe586b31cea1143132f3a39e4 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 21 Jul 2008 19:03:49 +0100 Subject: [PATCH 03/14] Rename path_list to string_list The name path_list was correct for the first usage of that data structure, but it really is a general-purpose string list. $ perl -i -pe 's/path-list/string-list/g' $(git grep -l path-list) $ perl -i -pe 's/path_list/string_list/g' $(git grep -l path_list) $ git mv path-list.h string-list.h $ git mv path-list.c string-list.c $ perl -i -pe 's/has_path/has_string/g' $(git grep -l has_path) $ perl -i -pe 's/path/string/g' string-list.[ch] $ git mv Documentation/technical/api-path-list.txt \ Documentation/technical/api-string-list.txt $ perl -i -pe 's/strdup_paths/strdup_strings/g' $(git grep -l strdup_paths) ... and then fix all users of string-list to access the member "string" instead of "path". Documentation/technical/api-string-list.txt needed some rewrapping, too. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- Documentation/CodingGuidelines | 2 +- Documentation/technical/api-path-list.txt | 126 ------------------ Documentation/technical/api-string-list.txt | 128 +++++++++++++++++++ Makefile | 4 +- builtin-apply.c | 16 +-- builtin-blame.c | 10 +- builtin-commit.c | 20 +-- builtin-fast-export.c | 14 +- builtin-fetch.c | 20 +-- builtin-mailsplit.c | 12 +- builtin-merge-recursive.c | 96 +++++++------- builtin-mv.c | 39 +++--- builtin-remote.c | 124 +++++++++--------- builtin-rerere.c | 20 +-- builtin-shortlog.c | 42 +++--- builtin-show-ref.c | 10 +- diff-no-index.c | 22 ++-- mailmap.c | 12 +- mailmap.h | 4 +- path-list.c | 134 -------------------- path-list.h | 28 ---- pretty.c | 4 +- reflog-walk.c | 10 +- rerere.c | 40 +++--- rerere.h | 4 +- shortlog.h | 6 +- string-list.c | 134 ++++++++++++++++++++ string-list.h | 28 ++++ 28 files changed, 556 insertions(+), 553 deletions(-) delete mode 100644 Documentation/technical/api-path-list.txt create mode 100644 Documentation/technical/api-string-list.txt delete mode 100644 path-list.c delete mode 100644 path-list.h create mode 100644 string-list.c create mode 100644 string-list.h diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines index d2a0a76e6c..f628c1f3b7 100644 --- a/Documentation/CodingGuidelines +++ b/Documentation/CodingGuidelines @@ -105,7 +105,7 @@ For C programs: - Use the API. No, really. We have a strbuf (variable length string), several arrays with the ALLOC_GROW() macro, a - path_list for sorted string lists, a hash map (mapping struct + string_list for sorted string lists, a hash map (mapping struct objects) named "struct decorate", amongst other things. - When you come up with an API, document it. diff --git a/Documentation/technical/api-path-list.txt b/Documentation/technical/api-path-list.txt deleted file mode 100644 index 9dbedd0a67..0000000000 --- a/Documentation/technical/api-path-list.txt +++ /dev/null @@ -1,126 +0,0 @@ -path-list API -============= - -The path_list API offers a data structure and functions to handle sorted -and unsorted string lists. - -The name is a bit misleading, a path_list may store not only paths but -strings in general. - -The caller: - -. Allocates and clears a `struct path_list` variable. - -. Initializes the members. You might want to set the flag `strdup_paths` - if the strings should be strdup()ed. For example, this is necessary - when you add something like git_path("..."), since that function returns - a static buffer that will change with the next call to git_path(). -+ -If you need something advanced, you can manually malloc() the `items` -member (you need this if you add things later) and you should set the -`nr` and `alloc` members in that case, too. - -. Adds new items to the list, using `path_list_append` or `path_list_insert`. - -. Can check if a string is in the list using `path_list_has_path` or - `unsorted_path_list_has_path` and get it from the list using - `path_list_lookup` for sorted lists. - -. Can sort an unsorted list using `sort_path_list`. - -. Finally it should free the list using `path_list_clear`. - -Example: - ----- -struct path_list list; -int i; - -memset(&list, 0, sizeof(struct path_list)); -path_list_append("foo", &list); -path_list_append("bar", &list); -for (i = 0; i < list.nr; i++) - printf("%s\n", list.items[i].path) ----- - -NOTE: It is more efficient to build an unsorted list and sort it -afterwards, instead of building a sorted list (`O(n log n)` instead of -`O(n^2)`). -+ -However, if you use the list to check if a certain string was added -already, you should not do that (using unsorted_path_list_has_path()), -because the complexity would be quadratic again (but with a worse factor). - -Functions ---------- - -* General ones (works with sorted and unsorted lists as well) - -`print_path_list`:: - - Dump a path_list to stdout, useful mainly for debugging purposes. It - can take an optional header argument and it writes out the - string-pointer pairs of the path_list, each one in its own line. - -`path_list_clear`:: - - Free a path_list. The `path` pointer of the items will be freed in case - the `strdup_paths` member of the path_list is set. The second parameter - controls if the `util` pointer of the items should be freed or not. - -* Functions for sorted lists only - -`path_list_has_path`:: - - Determine if the path_list has a given string or not. - -`path_list_insert`:: - - Insert a new element to the path_list. The returned pointer can be handy - if you want to write something to the `util` pointer of the - path_list_item containing the just added string. -+ -Since this function uses xrealloc() (which die()s if it fails) if the -list needs to grow, it is safe not to check the pointer. I.e. you may -write `path_list_insert(...)->util = ...;`. - -`path_list_lookup`:: - - Look up a given string in the path_list, returning the containing - path_list_item. If the string is not found, NULL is returned. - -* Functions for unsorted lists only - -`path_list_append`:: - - Append a new string to the end of the path_list. - -`sort_path_list`:: - - Make an unsorted list sorted. - -`unsorted_path_list_has_path`:: - - It's like `path_list_has_path()` but for unsorted lists. -+ -This function needs to look through all items, as opposed to its -counterpart for sorted lists, which performs a binary search. - -Data structures ---------------- - -* `struct path_list_item` - -Represents an item of the list. The `path` member is a pointer to the -string, and you may use the `util` member for any purpose, if you want. - -* `struct path_list` - -Represents the list itself. - -. The array of items are available via the `items` member. -. The `nr` member contains the number of items stored in the list. -. The `alloc` member is used to avoid reallocating at every insertion. - You should not tamper with it. -. Setting the `strdup_paths` member to 1 will strdup() the strings - before adding them, see above. diff --git a/Documentation/technical/api-string-list.txt b/Documentation/technical/api-string-list.txt new file mode 100644 index 0000000000..92b3ecdae2 --- /dev/null +++ b/Documentation/technical/api-string-list.txt @@ -0,0 +1,128 @@ +string-list API +=============== + +The string_list API offers a data structure and functions to handle sorted +and unsorted string lists. + +The 'string_list' struct used to be called 'path_list', but was renamed +because it is not specific to paths. + +The caller: + +. Allocates and clears a `struct string_list` variable. + +. Initializes the members. You might want to set the flag `strdup_strings` + if the strings should be strdup()ed. For example, this is necessary + when you add something like git_path("..."), since that function returns + a static buffer that will change with the next call to git_path(). ++ +If you need something advanced, you can manually malloc() the `items` +member (you need this if you add things later) and you should set the +`nr` and `alloc` members in that case, too. + +. Adds new items to the list, using `string_list_append` or + `string_list_insert`. + +. Can check if a string is in the list using `string_list_has_string` or + `unsorted_string_list_has_string` and get it from the list using + `string_list_lookup` for sorted lists. + +. Can sort an unsorted list using `sort_string_list`. + +. Finally it should free the list using `string_list_clear`. + +Example: + +---- +struct string_list list; +int i; + +memset(&list, 0, sizeof(struct string_list)); +string_list_append("foo", &list); +string_list_append("bar", &list); +for (i = 0; i < list.nr; i++) + printf("%s\n", list.items[i].path) +---- + +NOTE: It is more efficient to build an unsorted list and sort it +afterwards, instead of building a sorted list (`O(n log n)` instead of +`O(n^2)`). ++ +However, if you use the list to check if a certain string was added +already, you should not do that (using unsorted_string_list_has_string()), +because the complexity would be quadratic again (but with a worse factor). + +Functions +--------- + +* General ones (works with sorted and unsorted lists as well) + +`print_string_list`:: + + Dump a string_list to stdout, useful mainly for debugging purposes. It + can take an optional header argument and it writes out the + string-pointer pairs of the string_list, each one in its own line. + +`string_list_clear`:: + + Free a string_list. The `string` pointer of the items will be freed in + case the `strdup_strings` member of the string_list is set. The second + parameter controls if the `util` pointer of the items should be freed + or not. + +* Functions for sorted lists only + +`string_list_has_string`:: + + Determine if the string_list has a given string or not. + +`string_list_insert`:: + + Insert a new element to the string_list. The returned pointer can be + handy if you want to write something to the `util` pointer of the + string_list_item containing the just added string. ++ +Since this function uses xrealloc() (which die()s if it fails) if the +list needs to grow, it is safe not to check the pointer. I.e. you may +write `string_list_insert(...)->util = ...;`. + +`string_list_lookup`:: + + Look up a given string in the string_list, returning the containing + string_list_item. If the string is not found, NULL is returned. + +* Functions for unsorted lists only + +`string_list_append`:: + + Append a new string to the end of the string_list. + +`sort_string_list`:: + + Make an unsorted list sorted. + +`unsorted_string_list_has_string`:: + + It's like `string_list_has_string()` but for unsorted lists. ++ +This function needs to look through all items, as opposed to its +counterpart for sorted lists, which performs a binary search. + +Data structures +--------------- + +* `struct string_list_item` + +Represents an item of the list. The `path` member is a pointer to the +string, and you may use the `util` member for any purpose, if you want. + +* `struct string_list` + +Represents the list itself. + +. The array of items are available via the `items` member. +. The `nr` member contains the number of items stored in the list. +. The `alloc` member is used to avoid reallocating at every insertion. + You should not tamper with it. +. Setting the `strdup_strings` member to 1 will strdup() the strings + before adding them, see above. diff --git a/Makefile b/Makefile index 551bde9ff0..b01cf1c993 100644 --- a/Makefile +++ b/Makefile @@ -356,7 +356,7 @@ LIB_H += pack-refs.h LIB_H += pack-revindex.h LIB_H += parse-options.h LIB_H += patch-ids.h -LIB_H += path-list.h +LIB_H += string-list.h LIB_H += pkt-line.h LIB_H += progress.h LIB_H += quote.h @@ -437,7 +437,7 @@ LIB_OBJS += pager.o LIB_OBJS += parse-options.o LIB_OBJS += patch-delta.o LIB_OBJS += patch-ids.o -LIB_OBJS += path-list.o +LIB_OBJS += string-list.o LIB_OBJS += path.o LIB_OBJS += pkt-line.o LIB_OBJS += pretty.o diff --git a/builtin-apply.c b/builtin-apply.c index e15471b5b6..2216a0bf7c 100644 --- a/builtin-apply.c +++ b/builtin-apply.c @@ -12,7 +12,7 @@ #include "blob.h" #include "delta.h" #include "builtin.h" -#include "path-list.h" +#include "string-list.h" /* * --check turns on checking that the working tree matches the @@ -194,7 +194,7 @@ struct image { * the case where more than one patches touch the same file. */ -static struct path_list fn_table; +static struct string_list fn_table; static uint32_t hash_line(const char *cp, size_t len) { @@ -2250,12 +2250,12 @@ static int read_file_or_gitlink(struct cache_entry *ce, struct strbuf *buf) static struct patch *in_fn_table(const char *name) { - struct path_list_item *item; + struct string_list_item *item; if (name == NULL) return NULL; - item = path_list_lookup(name, &fn_table); + item = string_list_lookup(name, &fn_table); if (item != NULL) return (struct patch *)item->util; @@ -2264,7 +2264,7 @@ static struct patch *in_fn_table(const char *name) static void add_to_fn_table(struct patch *patch) { - struct path_list_item *item; + struct string_list_item *item; /* * Always add new_name unless patch is a deletion @@ -2272,7 +2272,7 @@ static void add_to_fn_table(struct patch *patch) * file creations and copies */ if (patch->new_name != NULL) { - item = path_list_insert(patch->new_name, &fn_table); + item = string_list_insert(patch->new_name, &fn_table); item->util = patch; } @@ -2281,7 +2281,7 @@ static void add_to_fn_table(struct patch *patch) * later chunks shouldn't patch old names */ if ((patch->new_name == NULL) || (patch->is_rename)) { - item = path_list_insert(patch->old_name, &fn_table); + item = string_list_insert(patch->old_name, &fn_table); item->util = (struct patch *) -1; } } @@ -3051,7 +3051,7 @@ static int apply_patch(int fd, const char *filename, int options) int skipped_patch = 0; /* FIXME - memory leak when using multiple patch files as inputs */ - memset(&fn_table, 0, sizeof(struct path_list)); + memset(&fn_table, 0, sizeof(struct string_list)); strbuf_init(&buf, 0); patch_input_file = filename; read_patch_file(&buf, fd); diff --git a/builtin-blame.c b/builtin-blame.c index 9bced3b262..8b6b09b10b 100644 --- a/builtin-blame.c +++ b/builtin-blame.c @@ -16,7 +16,7 @@ #include "quote.h" #include "xdiff-interface.h" #include "cache-tree.h" -#include "path-list.h" +#include "string-list.h" #include "mailmap.h" #include "parse-options.h" @@ -40,7 +40,7 @@ static int blank_boundary; static int incremental; static int cmd_is_annotate; static int xdl_opts = XDF_NEED_MINIMAL; -static struct path_list mailmap; +static struct string_list mailmap; #ifndef DEBUG #define DEBUG 0 @@ -1926,7 +1926,7 @@ static void sanity_check_refcnt(struct scoreboard *sb) * Used for the command line parsing; check if the path exists * in the working tree. */ -static int has_path_in_work_tree(const char *path) +static int has_string_in_work_tree(const char *path) { struct stat st; return !lstat(path, &st); @@ -2390,14 +2390,14 @@ parse_done: if (argc < 2) usage_with_options(blame_opt_usage, options); path = add_prefix(prefix, argv[argc - 1]); - if (argc == 3 && !has_path_in_work_tree(path)) { /* (2b) */ + if (argc == 3 && !has_string_in_work_tree(path)) { /* (2b) */ path = add_prefix(prefix, argv[1]); argv[1] = argv[2]; } argv[argc - 1] = "--"; setup_work_tree(); - if (!has_path_in_work_tree(path)) + if (!has_string_in_work_tree(path)) die("cannot stat path %s: %s", path, strerror(errno)); } diff --git a/builtin-commit.c b/builtin-commit.c index ed3fe3f7ee..97e64de312 100644 --- a/builtin-commit.c +++ b/builtin-commit.c @@ -21,7 +21,7 @@ #include "strbuf.h" #include "utf8.h" #include "parse-options.h" -#include "path-list.h" +#include "string-list.h" #include "rerere.h" #include "unpack-trees.h" @@ -150,7 +150,7 @@ static int commit_index_files(void) * Take a union of paths in the index and the named tree (typically, "HEAD"), * and return the paths that match the given pattern in list. */ -static int list_paths(struct path_list *list, const char *with_tree, +static int list_paths(struct string_list *list, const char *with_tree, const char *prefix, const char **pattern) { int i; @@ -169,24 +169,24 @@ static int list_paths(struct path_list *list, const char *with_tree, continue; if (!pathspec_match(pattern, m, ce->name, 0)) continue; - path_list_insert(ce->name, list); + string_list_insert(ce->name, list); } return report_path_error(m, pattern, prefix ? strlen(prefix) : 0); } -static void add_remove_files(struct path_list *list) +static void add_remove_files(struct string_list *list) { int i; for (i = 0; i < list->nr; i++) { struct stat st; - struct path_list_item *p = &(list->items[i]); + struct string_list_item *p = &(list->items[i]); - if (!lstat(p->path, &st)) { - if (add_to_cache(p->path, &st, 0)) + if (!lstat(p->string, &st)) { + if (add_to_cache(p->string, &st, 0)) die("updating files failed"); } else - remove_file_from_cache(p->path); + remove_file_from_cache(p->string); } } @@ -221,7 +221,7 @@ static void create_base_index(void) static char *prepare_index(int argc, const char **argv, const char *prefix) { int fd; - struct path_list partial; + struct string_list partial; const char **pathspec = NULL; if (interactive) { @@ -305,7 +305,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix) die("cannot do a partial commit during a merge."); memset(&partial, 0, sizeof(partial)); - partial.strdup_paths = 1; + partial.strdup_strings = 1; if (list_paths(&partial, initial_commit ? NULL : "HEAD", prefix, pathspec)) exit(1); diff --git a/builtin-fast-export.c b/builtin-fast-export.c index a443d59460..e508ced6ba 100644 --- a/builtin-fast-export.c +++ b/builtin-fast-export.c @@ -13,7 +13,7 @@ #include "log-tree.h" #include "revision.h" #include "decorate.h" -#include "path-list.h" +#include "string-list.h" #include "utf8.h" #include "parse-options.h" @@ -309,7 +309,7 @@ static void handle_tag(const char *name, struct tag *tag) } static void get_tags_and_duplicates(struct object_array *pending, - struct path_list *extra_refs) + struct string_list *extra_refs) { struct tag *tag; int i; @@ -330,7 +330,7 @@ static void get_tags_and_duplicates(struct object_array *pending, case OBJ_TAG: tag = (struct tag *)e->item; while (tag && tag->object.type == OBJ_TAG) { - path_list_insert(full_name, extra_refs)->util = tag; + string_list_insert(full_name, extra_refs)->util = tag; tag = (struct tag *)tag->tagged; } if (!tag) @@ -350,19 +350,19 @@ static void get_tags_and_duplicates(struct object_array *pending, } if (commit->util) /* more than one name for the same object */ - path_list_insert(full_name, extra_refs)->util = commit; + string_list_insert(full_name, extra_refs)->util = commit; else commit->util = full_name; } } -static void handle_tags_and_duplicates(struct path_list *extra_refs) +static void handle_tags_and_duplicates(struct string_list *extra_refs) { struct commit *commit; int i; for (i = extra_refs->nr - 1; i >= 0; i--) { - const char *name = extra_refs->items[i].path; + const char *name = extra_refs->items[i].string; struct object *object = extra_refs->items[i].util; switch (object->type) { case OBJ_TAG: @@ -445,7 +445,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix) { struct rev_info revs; struct object_array commits = { 0, 0, NULL }; - struct path_list extra_refs = { NULL, 0, 0, 0 }; + struct string_list extra_refs = { NULL, 0, 0, 0 }; struct commit *commit; char *export_filename = NULL, *import_filename = NULL; struct option options[] = { diff --git a/builtin-fetch.c b/builtin-fetch.c index 61de50a020..7eec4a0e43 100644 --- a/builtin-fetch.c +++ b/builtin-fetch.c @@ -5,7 +5,7 @@ #include "refs.h" #include "commit.h" #include "builtin.h" -#include "path-list.h" +#include "string-list.h" #include "remote.h" #include "transport.h" #include "run-command.h" @@ -465,8 +465,8 @@ static int fetch_refs(struct transport *transport, struct ref *ref_map) 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); + struct string_list *list = (struct string_list *)cbdata; + string_list_insert(refname, list); return 0; } @@ -485,8 +485,8 @@ static void find_non_local_tags(struct transport *transport, struct ref **head, struct ref ***tail) { - struct path_list existing_refs = { NULL, 0, 0, 0 }; - struct path_list new_refs = { NULL, 0, 0, 1 }; + struct string_list existing_refs = { NULL, 0, 0, 0 }; + struct string_list new_refs = { NULL, 0, 0, 1 }; char *ref_name; int ref_name_len; const unsigned char *ref_sha1; @@ -515,11 +515,11 @@ static void find_non_local_tags(struct transport *transport, } } - if (!path_list_has_path(&existing_refs, ref_name) && - !path_list_has_path(&new_refs, ref_name) && + if (!string_list_has_string(&existing_refs, ref_name) && + !string_list_has_string(&new_refs, ref_name) && (has_sha1_file(ref->old_sha1) || will_fetch(head, ref->old_sha1))) { - path_list_insert(ref_name, &new_refs); + string_list_insert(ref_name, &new_refs); rm = alloc_ref_from_str(ref_name); rm->peer_ref = alloc_ref_from_str(ref_name); @@ -530,8 +530,8 @@ static void find_non_local_tags(struct transport *transport, } free(ref_name); } - path_list_clear(&existing_refs, 0); - path_list_clear(&new_refs, 0); + string_list_clear(&existing_refs, 0); + string_list_clear(&new_refs, 0); } static int do_fetch(struct transport *transport, diff --git a/builtin-mailsplit.c b/builtin-mailsplit.c index 13c60c39a4..71f3b3b874 100644 --- a/builtin-mailsplit.c +++ b/builtin-mailsplit.c @@ -6,7 +6,7 @@ */ #include "cache.h" #include "builtin.h" -#include "path-list.h" +#include "string-list.h" static const char git_mailsplit_usage[] = "git mailsplit [-d] [-f] [-b] -o [|...]"; @@ -115,7 +115,7 @@ static int split_one(FILE *mbox, const char *name, int allow_bare) exit(1); } -static int populate_maildir_list(struct path_list *list, const char *path) +static int populate_maildir_list(struct string_list *list, const char *path) { DIR *dir; struct dirent *dent; @@ -136,7 +136,7 @@ static int populate_maildir_list(struct path_list *list, const char *path) if (dent->d_name[0] == '.') continue; snprintf(name, sizeof(name), "%s/%s", *sub, dent->d_name); - path_list_insert(name, list); + string_list_insert(name, list); } closedir(dir); @@ -152,14 +152,14 @@ static int split_maildir(const char *maildir, const char *dir, char name[PATH_MAX]; int ret = -1; int i; - struct path_list list = {NULL, 0, 0, 1}; + struct string_list list = {NULL, 0, 0, 1}; if (populate_maildir_list(&list, maildir) < 0) goto out; for (i = 0; i < list.nr; i++) { FILE *f; - snprintf(file, sizeof(file), "%s/%s", maildir, list.items[i].path); + snprintf(file, sizeof(file), "%s/%s", maildir, list.items[i].string); f = fopen(file, "r"); if (!f) { error("cannot open mail %s (%s)", file, strerror(errno)); @@ -179,7 +179,7 @@ static int split_maildir(const char *maildir, const char *dir, ret = skip; out: - path_list_clear(&list, 1); + string_list_clear(&list, 1); return ret; } diff --git a/builtin-merge-recursive.c b/builtin-merge-recursive.c index 652a2c32bb..43e55bf901 100644 --- a/builtin-merge-recursive.c +++ b/builtin-merge-recursive.c @@ -13,7 +13,7 @@ #include "diffcore.h" #include "tag.h" #include "unpack-trees.h" -#include "path-list.h" +#include "string-list.h" #include "xdiff-interface.h" #include "ll-merge.h" #include "interpolate.h" @@ -79,8 +79,8 @@ struct stage_data unsigned processed:1; }; -static struct path_list current_file_set = {NULL, 0, 0, 1}; -static struct path_list current_directory_set = {NULL, 0, 0, 1}; +static struct string_list current_file_set = {NULL, 0, 0, 1}; +static struct string_list current_directory_set = {NULL, 0, 0, 1}; static int call_depth = 0; static int verbosity = 2; @@ -257,9 +257,9 @@ static int save_files_dirs(const unsigned char *sha1, newpath[baselen + len] = '\0'; if (S_ISDIR(mode)) - path_list_insert(newpath, ¤t_directory_set); + string_list_insert(newpath, ¤t_directory_set); else - path_list_insert(newpath, ¤t_file_set); + string_list_insert(newpath, ¤t_file_set); free(newpath); return READ_TREE_RECURSIVE; @@ -280,9 +280,9 @@ static int get_files_dirs(struct tree *tree) */ static struct stage_data *insert_stage_data(const char *path, struct tree *o, struct tree *a, struct tree *b, - struct path_list *entries) + struct string_list *entries) { - struct path_list_item *item; + struct string_list_item *item; struct stage_data *e = xcalloc(1, sizeof(struct stage_data)); get_tree_entry(o->object.sha1, path, e->stages[1].sha, &e->stages[1].mode); @@ -290,7 +290,7 @@ static struct stage_data *insert_stage_data(const char *path, e->stages[2].sha, &e->stages[2].mode); get_tree_entry(b->object.sha1, path, e->stages[3].sha, &e->stages[3].mode); - item = path_list_insert(path, entries); + item = string_list_insert(path, entries); item->util = e; return e; } @@ -299,23 +299,23 @@ static struct stage_data *insert_stage_data(const char *path, * Create a dictionary mapping file names to stage_data objects. The * dictionary contains one entry for every path with a non-zero stage entry. */ -static struct path_list *get_unmerged(void) +static struct string_list *get_unmerged(void) { - struct path_list *unmerged = xcalloc(1, sizeof(struct path_list)); + struct string_list *unmerged = xcalloc(1, sizeof(struct string_list)); int i; - unmerged->strdup_paths = 1; + unmerged->strdup_strings = 1; for (i = 0; i < active_nr; i++) { - struct path_list_item *item; + struct string_list_item *item; struct stage_data *e; struct cache_entry *ce = active_cache[i]; if (!ce_stage(ce)) continue; - item = path_list_lookup(ce->name, unmerged); + item = string_list_lookup(ce->name, unmerged); if (!item) { - item = path_list_insert(ce->name, unmerged); + item = string_list_insert(ce->name, unmerged); item->util = xcalloc(1, sizeof(struct stage_data)); } e = item->util; @@ -340,17 +340,17 @@ struct rename * 'b_tree') to be able to associate the correct cache entries with * the rename information. 'tree' is always equal to either a_tree or b_tree. */ -static struct path_list *get_renames(struct tree *tree, +static struct string_list *get_renames(struct tree *tree, struct tree *o_tree, struct tree *a_tree, struct tree *b_tree, - struct path_list *entries) + struct string_list *entries) { int i; - struct path_list *renames; + struct string_list *renames; struct diff_options opts; - renames = xcalloc(1, sizeof(struct path_list)); + renames = xcalloc(1, sizeof(struct string_list)); diff_setup(&opts); DIFF_OPT_SET(&opts, RECURSIVE); opts.detect_rename = DIFF_DETECT_RENAME; @@ -364,7 +364,7 @@ static struct path_list *get_renames(struct tree *tree, diff_tree_sha1(o_tree->object.sha1, tree->object.sha1, "", &opts); diffcore_std(&opts); for (i = 0; i < diff_queued_diff.nr; ++i) { - struct path_list_item *item; + struct string_list_item *item; struct rename *re; struct diff_filepair *pair = diff_queued_diff.queue[i]; if (pair->status != 'R') { @@ -374,20 +374,20 @@ static struct path_list *get_renames(struct tree *tree, re = xmalloc(sizeof(*re)); re->processed = 0; re->pair = pair; - item = path_list_lookup(re->pair->one->path, entries); + item = string_list_lookup(re->pair->one->path, entries); if (!item) re->src_entry = insert_stage_data(re->pair->one->path, o_tree, a_tree, b_tree, entries); else re->src_entry = item->util; - item = path_list_lookup(re->pair->two->path, entries); + item = string_list_lookup(re->pair->two->path, entries); if (!item) re->dst_entry = insert_stage_data(re->pair->two->path, o_tree, a_tree, b_tree, entries); else re->dst_entry = item->util; - item = path_list_insert(pair->one->path, renames); + item = string_list_insert(pair->one->path, renames); item->util = re; } opts.output_format = DIFF_FORMAT_NO_OUTPUT; @@ -464,12 +464,12 @@ static char *unique_path(const char *path, const char *branch) for (; *p; ++p) if ('/' == *p) *p = '_'; - while (path_list_has_path(¤t_file_set, newpath) || - path_list_has_path(¤t_directory_set, newpath) || + while (string_list_has_string(¤t_file_set, newpath) || + string_list_has_string(¤t_directory_set, newpath) || lstat(newpath, &st) == 0) sprintf(p, "_%d", suffix++); - path_list_insert(newpath, ¤t_file_set); + string_list_insert(newpath, ¤t_file_set); return newpath; } @@ -727,13 +727,13 @@ static void conflict_rename_rename(struct rename *ren1, const char *ren2_dst = ren2->pair->two->path; const char *dst_name1 = ren1_dst; const char *dst_name2 = ren2_dst; - if (path_list_has_path(¤t_directory_set, ren1_dst)) { + if (string_list_has_string(¤t_directory_set, ren1_dst)) { dst_name1 = del[delp++] = unique_path(ren1_dst, branch1); output(1, "%s is a directory in %s added as %s instead", ren1_dst, branch2, dst_name1); remove_file(0, ren1_dst, 0); } - if (path_list_has_path(¤t_directory_set, ren2_dst)) { + if (string_list_has_string(¤t_directory_set, ren2_dst)) { dst_name2 = del[delp++] = unique_path(ren2_dst, branch2); output(1, "%s is a directory in %s added as %s instead", ren2_dst, branch1, dst_name2); @@ -783,30 +783,30 @@ static void conflict_rename_rename_2(struct rename *ren1, free(new_path1); } -static int process_renames(struct path_list *a_renames, - struct path_list *b_renames, +static int process_renames(struct string_list *a_renames, + struct string_list *b_renames, const char *a_branch, const char *b_branch) { int clean_merge = 1, i, j; - struct path_list a_by_dst = {NULL, 0, 0, 0}, b_by_dst = {NULL, 0, 0, 0}; + struct string_list a_by_dst = {NULL, 0, 0, 0}, b_by_dst = {NULL, 0, 0, 0}; const struct rename *sre; for (i = 0; i < a_renames->nr; i++) { sre = a_renames->items[i].util; - path_list_insert(sre->pair->two->path, &a_by_dst)->util + string_list_insert(sre->pair->two->path, &a_by_dst)->util = sre->dst_entry; } for (i = 0; i < b_renames->nr; i++) { sre = b_renames->items[i].util; - path_list_insert(sre->pair->two->path, &b_by_dst)->util + string_list_insert(sre->pair->two->path, &b_by_dst)->util = sre->dst_entry; } for (i = 0, j = 0; i < a_renames->nr || j < b_renames->nr;) { int compare; char *src; - struct path_list *renames1, *renames2, *renames2Dst; + struct string_list *renames1, *renames2, *renames2Dst; struct rename *ren1 = NULL, *ren2 = NULL; const char *branch1, *branch2; const char *ren1_src, *ren1_dst; @@ -818,8 +818,8 @@ static int process_renames(struct path_list *a_renames, compare = -1; ren1 = a_renames->items[i++].util; } else { - compare = strcmp(a_renames->items[i].path, - b_renames->items[j].path); + compare = strcmp(a_renames->items[i].string, + b_renames->items[j].string); if (compare <= 0) ren1 = a_renames->items[i++].util; if (compare >= 0) @@ -908,7 +908,7 @@ static int process_renames(struct path_list *a_renames, } } else { /* Renamed in 1, maybe changed in 2 */ - struct path_list_item *item; + struct string_list_item *item; /* we only use sha1 and mode of these */ struct diff_filespec src_other, dst_other; int try_merge, stage = a_renames == renames1 ? 3: 2; @@ -922,7 +922,7 @@ static int process_renames(struct path_list *a_renames, try_merge = 0; - if (path_list_has_path(¤t_directory_set, ren1_dst)) { + if (string_list_has_string(¤t_directory_set, ren1_dst)) { clean_merge = 0; output(1, "CONFLICT (rename/directory): Renamed %s->%s in %s " " directory %s added in %s", @@ -947,7 +947,7 @@ static int process_renames(struct path_list *a_renames, new_path = unique_path(ren1_dst, branch2); output(1, "Added as %s instead", new_path); update_file(0, dst_other.sha1, dst_other.mode, new_path); - } else if ((item = path_list_lookup(ren1_dst, renames2Dst))) { + } else if ((item = string_list_lookup(ren1_dst, renames2Dst))) { ren2 = item->util; clean_merge = 0; ren2->processed = 1; @@ -1003,8 +1003,8 @@ static int process_renames(struct path_list *a_renames, } } } - path_list_clear(&a_by_dst, 0); - path_list_clear(&b_by_dst, 0); + string_list_clear(&a_by_dst, 0); + string_list_clear(&b_by_dst, 0); return clean_merge; } @@ -1082,7 +1082,7 @@ static int process_entry(const char *path, struct stage_data *entry, sha = b_sha; conf = "directory/file"; } - if (path_list_has_path(¤t_directory_set, path)) { + if (string_list_has_string(¤t_directory_set, path)) { const char *new_path = unique_path(path, add_branch); clean_merge = 0; output(1, "CONFLICT (%s): There is a directory with name %s in %s. " @@ -1173,10 +1173,10 @@ int merge_trees(struct tree *head, sha1_to_hex(merge->object.sha1)); if (unmerged_cache()) { - struct path_list *entries, *re_head, *re_merge; + struct string_list *entries, *re_head, *re_merge; int i; - path_list_clear(¤t_file_set, 1); - path_list_clear(¤t_directory_set, 1); + string_list_clear(¤t_file_set, 1); + string_list_clear(¤t_directory_set, 1); get_files_dirs(head); get_files_dirs(merge); @@ -1186,16 +1186,16 @@ int merge_trees(struct tree *head, clean = process_renames(re_head, re_merge, branch1, branch2); for (i = 0; i < entries->nr; i++) { - const char *path = entries->items[i].path; + const char *path = entries->items[i].string; struct stage_data *e = entries->items[i].util; if (!e->processed && !process_entry(path, e, branch1, branch2)) clean = 0; } - path_list_clear(re_merge, 0); - path_list_clear(re_head, 0); - path_list_clear(entries, 1); + string_list_clear(re_merge, 0); + string_list_clear(re_head, 0); + string_list_clear(entries, 1); } else diff --git a/builtin-mv.c b/builtin-mv.c index ba9cedab6d..736a0b8bb1 100644 --- a/builtin-mv.c +++ b/builtin-mv.c @@ -7,7 +7,7 @@ #include "builtin.h" #include "dir.h" #include "cache-tree.h" -#include "path-list.h" +#include "string-list.h" #include "parse-options.h" static const char * const builtin_mv_usage[] = { @@ -36,13 +36,14 @@ static const char **copy_pathspec(const char *prefix, const char **pathspec, return get_pathspec(prefix, result); } -static void show_list(const char *label, struct path_list *list) +static void show_list(const char *label, struct string_list *list) { if (list->nr > 0) { int i; printf("%s", label); for (i = 0; i < list->nr; i++) - printf("%s%s", i > 0 ? ", " : "", list->items[i].path); + printf("%s%s", i > 0 ? ", " : "", + list->items[i].string); putchar('\n'); } } @@ -75,11 +76,11 @@ int cmd_mv(int argc, const char **argv, const char *prefix) const char **source, **destination, **dest_path; enum update_mode { BOTH = 0, WORKING_DIRECTORY, INDEX } *modes; struct stat st; - struct path_list overwritten = {NULL, 0, 0, 0}; - struct path_list src_for_dst = {NULL, 0, 0, 0}; - struct path_list added = {NULL, 0, 0, 0}; - struct path_list deleted = {NULL, 0, 0, 0}; - struct path_list changed = {NULL, 0, 0, 0}; + struct string_list overwritten = {NULL, 0, 0, 0}; + struct string_list src_for_dst = {NULL, 0, 0, 0}; + struct string_list added = {NULL, 0, 0, 0}; + struct string_list deleted = {NULL, 0, 0, 0}; + struct string_list changed = {NULL, 0, 0, 0}; git_config(git_default_config, NULL); @@ -189,16 +190,16 @@ int cmd_mv(int argc, const char **argv, const char *prefix) " will overwrite!\n", bad); bad = NULL; - path_list_insert(dst, &overwritten); + string_list_insert(dst, &overwritten); } else bad = "Cannot overwrite"; } } else if (cache_name_pos(src, length) < 0) bad = "not under version control"; - else if (path_list_has_path(&src_for_dst, dst)) + else if (string_list_has_string(&src_for_dst, dst)) bad = "multiple sources for the same target"; else - path_list_insert(dst, &src_for_dst); + string_list_insert(dst, &src_for_dst); if (bad) { if (ignore_errors) { @@ -228,15 +229,15 @@ int cmd_mv(int argc, const char **argv, const char *prefix) continue; if (cache_name_pos(src, strlen(src)) >= 0) { - path_list_insert(src, &deleted); + string_list_insert(src, &deleted); /* destination can be a directory with 1 file inside */ - if (path_list_has_path(&overwritten, dst)) - path_list_insert(dst, &changed); + if (string_list_has_string(&overwritten, dst)) + string_list_insert(dst, &changed); else - path_list_insert(dst, &added); + string_list_insert(dst, &added); } else - path_list_insert(dst, &added); + string_list_insert(dst, &added); } if (show_only) { @@ -245,7 +246,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix) show_list("Deleting : ", &deleted); } else { for (i = 0; i < changed.nr; i++) { - const char *path = changed.items[i].path; + const char *path = changed.items[i].string; int j = cache_name_pos(path, strlen(path)); struct cache_entry *ce = active_cache[j]; @@ -255,13 +256,13 @@ int cmd_mv(int argc, const char **argv, const char *prefix) } for (i = 0; i < added.nr; i++) { - const char *path = added.items[i].path; + const char *path = added.items[i].string; if (add_file_to_cache(path, verbose ? ADD_CACHE_VERBOSE : 0)) die("updating index entries failed"); } for (i = 0; i < deleted.nr; i++) - remove_file_from_cache(deleted.items[i].path); + remove_file_from_cache(deleted.items[i].string); if (active_cache_changed) { if (write_cache(newfd, active_cache, active_nr) || diff --git a/builtin-remote.c b/builtin-remote.c index db12668cfe..54d1c3e3d1 100644 --- a/builtin-remote.c +++ b/builtin-remote.c @@ -2,7 +2,7 @@ #include "parse-options.h" #include "transport.h" #include "remote.h" -#include "path-list.h" +#include "string-list.h" #include "strbuf.h" #include "run-command.h" #include "refs.h" @@ -31,11 +31,11 @@ static inline int postfixcmp(const char *string, const char *postfix) static int opt_parse_track(const struct option *opt, const char *arg, int not) { - struct path_list *list = opt->value; + struct string_list *list = opt->value; if (not) - path_list_clear(list, 0); + string_list_clear(list, 0); else - path_list_append(arg, list); + string_list_append(arg, list); return 0; } @@ -51,7 +51,7 @@ static int fetch_remote(const char *name) static int add(int argc, const char **argv) { int fetch = 0, mirror = 0; - struct path_list track = { NULL, 0, 0 }; + struct string_list track = { NULL, 0, 0 }; const char *master = NULL; struct remote *remote; struct strbuf buf, buf2; @@ -96,18 +96,18 @@ static int add(int argc, const char **argv) strbuf_addf(&buf, "remote.%s.fetch", name); if (track.nr == 0) - path_list_append("*", &track); + string_list_append("*", &track); for (i = 0; i < track.nr; i++) { - struct path_list_item *item = track.items + i; + struct string_list_item *item = track.items + i; strbuf_reset(&buf2); strbuf_addch(&buf2, '+'); if (mirror) strbuf_addf(&buf2, "refs/%s:refs/%s", - item->path, item->path); + item->string, item->string); else strbuf_addf(&buf2, "refs/heads/%s:refs/remotes/%s/%s", - item->path, name, item->path); + item->string, name, item->string); if (git_config_set_multivar(buf.buf, buf2.buf, "^$", 0)) return 1; } @@ -135,17 +135,17 @@ static int add(int argc, const char **argv) strbuf_release(&buf); strbuf_release(&buf2); - path_list_clear(&track, 0); + string_list_clear(&track, 0); return 0; } struct branch_info { char *remote; - struct path_list merge; + struct string_list merge; }; -static struct path_list branch_list; +static struct string_list branch_list; static const char *abbrev_ref(const char *name, const char *prefix) { @@ -160,7 +160,7 @@ static int config_read_branches(const char *key, const char *value, void *cb) { if (!prefixcmp(key, "branch.")) { char *name; - struct path_list_item *item; + struct string_list_item *item; struct branch_info *info; enum { REMOTE, MERGE } type; @@ -174,7 +174,7 @@ static int config_read_branches(const char *key, const char *value, void *cb) } else return 0; - item = path_list_insert(name, &branch_list); + item = string_list_insert(name, &branch_list); if (!item->util) item->util = xcalloc(sizeof(struct branch_info), 1); @@ -189,11 +189,11 @@ static int config_read_branches(const char *key, const char *value, void *cb) while (space) { char *merge; merge = xstrndup(value, space - value); - path_list_append(merge, &info->merge); + string_list_append(merge, &info->merge); value = abbrev_branch(space + 1); space = strchr(value, ' '); } - path_list_append(xstrdup(value), &info->merge); + string_list_append(xstrdup(value), &info->merge); } } return 0; @@ -204,12 +204,12 @@ static void read_branches(void) if (branch_list.nr) return; git_config(config_read_branches, NULL); - sort_path_list(&branch_list); + sort_string_list(&branch_list); } struct ref_states { struct remote *remote; - struct path_list new, stale, tracked; + struct string_list new, stale, tracked; }; static int handle_one_branch(const char *refname, @@ -221,16 +221,16 @@ static int handle_one_branch(const char *refname, memset(&refspec, 0, sizeof(refspec)); refspec.dst = (char *)refname; if (!remote_find_tracking(states->remote, &refspec)) { - struct path_list_item *item; + struct string_list_item *item; const char *name = abbrev_branch(refspec.src); /* symbolic refs pointing nowhere were handled already */ if ((flags & REF_ISSYMREF) || - unsorted_path_list_has_path(&states->tracked, + unsorted_string_list_has_string(&states->tracked, name) || - unsorted_path_list_has_path(&states->new, + unsorted_string_list_has_string(&states->new, name)) return 0; - item = path_list_append(name, &states->stale); + item = string_list_append(name, &states->stale); item->util = xstrdup(refname); } return 0; @@ -246,9 +246,9 @@ static int get_ref_states(const struct ref *ref, struct ref_states *states) die("Could not get fetch map for refspec %s", states->remote->fetch_refspec[i]); - states->new.strdup_paths = states->tracked.strdup_paths = 1; + states->new.strdup_strings = states->tracked.strdup_strings = 1; for (ref = fetch_map; ref; ref = ref->next) { - struct path_list *target = &states->tracked; + struct string_list *target = &states->tracked; unsigned char sha1[20]; void *util = NULL; @@ -259,12 +259,12 @@ static int get_ref_states(const struct ref *ref, struct ref_states *states) if (hashcmp(sha1, ref->new_sha1)) util = &states; } - path_list_append(abbrev_branch(ref->name), target)->util = util; + string_list_append(abbrev_branch(ref->name), target)->util = util; } free_refs(fetch_map); for_each_ref(handle_one_branch, states); - sort_path_list(&states->stale); + sort_string_list(&states->stale); return 0; } @@ -296,7 +296,7 @@ static int add_known_remote(struct remote *remote, void *cb_data) struct branches_for_remote { struct remote *remote; - struct path_list *branches; + struct string_list *branches; struct known_remotes *keep; }; @@ -305,7 +305,7 @@ static int add_branch_for_removal(const char *refname, { struct branches_for_remote *branches = cb_data; struct refspec refspec; - struct path_list_item *item; + struct string_list_item *item; struct known_remote *kr; memset(&refspec, 0, sizeof(refspec)); @@ -325,19 +325,19 @@ static int add_branch_for_removal(const char *refname, if (flags & REF_ISSYMREF) return unlink(git_path(refname)); - item = path_list_append(refname, branches->branches); + item = string_list_append(refname, branches->branches); item->util = xmalloc(20); hashcpy(item->util, sha1); return 0; } -static int remove_branches(struct path_list *branches) +static int remove_branches(struct string_list *branches) { int i, result = 0; for (i = 0; i < branches->nr; i++) { - struct path_list_item *item = branches->items + i; - const char *refname = item->path; + struct string_list_item *item = branches->items + i; + const char *refname = item->string; unsigned char *sha1 = item->util; if (delete_ref(refname, sha1)) @@ -354,7 +354,7 @@ static int rm(int argc, const char **argv) struct remote *remote; struct strbuf buf; struct known_remotes known_remotes = { NULL, NULL }; - struct path_list branches = { NULL, 0, 0, 1 }; + struct string_list branches = { NULL, 0, 0, 1 }; struct branches_for_remote cb_data = { NULL, &branches, &known_remotes }; int i; @@ -375,14 +375,14 @@ static int rm(int argc, const char **argv) read_branches(); for (i = 0; i < branch_list.nr; i++) { - struct path_list_item *item = branch_list.items + i; + struct string_list_item *item = branch_list.items + i; struct branch_info *info = item->util; if (info->remote && !strcmp(info->remote, remote->name)) { const char *keys[] = { "remote", "merge", NULL }, **k; for (k = keys; *k; k++) { strbuf_reset(&buf); strbuf_addf(&buf, "branch.%s.%s", - item->path, *k); + item->string, *k); if (git_config_set(buf.buf, NULL)) { strbuf_release(&buf); return -1; @@ -402,12 +402,12 @@ static int rm(int argc, const char **argv) if (!i) i = remove_branches(&branches); - path_list_clear(&branches, 1); + string_list_clear(&branches, 1); return i; } -static void show_list(const char *title, struct path_list *list) +static void show_list(const char *title, struct string_list *list) { int i; @@ -417,7 +417,7 @@ static void show_list(const char *title, struct path_list *list) printf(title, list->nr > 1 ? "es" : ""); printf("\n "); for (i = 0; i < list->nr; i++) - printf("%s%s", i ? " " : "", list->items[i].path); + printf("%s%s", i ? " " : "", list->items[i].string); printf("\n"); } @@ -455,7 +455,7 @@ static int append_ref_to_tracked_list(const char *refname, memset(&refspec, 0, sizeof(refspec)); refspec.dst = (char *)refname; if (!remote_find_tracking(states->remote, &refspec)) - path_list_append(abbrev_branch(refspec.src), &states->tracked); + string_list_append(abbrev_branch(refspec.src), &states->tracked); return 0; } @@ -487,7 +487,7 @@ static int show(int argc, const char **argv) states.remote->url[0] : "(no URL)"); for (i = 0; i < branch_list.nr; i++) { - struct path_list_item *branch = branch_list.items + i; + struct string_list_item *branch = branch_list.items + i; struct branch_info *info = branch->util; int j; @@ -496,9 +496,9 @@ static int show(int argc, const char **argv) printf(" Remote branch%s merged with 'git pull' " "while on branch %s\n ", info->merge.nr > 1 ? "es" : "", - branch->path); + branch->string); for (j = 0; j < info->merge.nr; j++) - printf(" %s", info->merge.items[j].path); + printf(" %s", info->merge.items[j].string); printf("\n"); } @@ -531,9 +531,9 @@ static int show(int argc, const char **argv) } /* NEEDSWORK: free remote */ - path_list_clear(&states.new, 0); - path_list_clear(&states.stale, 0); - path_list_clear(&states.tracked, 0); + string_list_clear(&states.new, 0); + string_list_clear(&states.stale, 0); + string_list_clear(&states.tracked, 0); } return result; @@ -579,9 +579,9 @@ static int prune(int argc, const char **argv) } /* NEEDSWORK: free remote */ - path_list_clear(&states.new, 0); - path_list_clear(&states.stale, 0); - path_list_clear(&states.tracked, 0); + string_list_clear(&states.new, 0); + string_list_clear(&states.stale, 0); + string_list_clear(&states.tracked, 0); } return result; @@ -589,15 +589,15 @@ static int prune(int argc, const char **argv) static int get_one_remote_for_update(struct remote *remote, void *priv) { - struct path_list *list = priv; + struct string_list *list = priv; if (!remote->skip_default_update) - path_list_append(xstrdup(remote->name), list); + string_list_append(xstrdup(remote->name), list); return 0; } struct remote_group { const char *name; - struct path_list *list; + struct string_list *list; } remote_group; static int get_remote_group(const char *key, const char *value, void *cb) @@ -608,7 +608,7 @@ static int get_remote_group(const char *key, const char *value, void *cb) int space = strcspn(value, " \t\n"); while (*value) { if (space > 1) - path_list_append(xstrndup(value, space), + string_list_append(xstrndup(value, space), remote_group.list); value += space + (value[space] != '\0'); space = strcspn(value, " \t\n"); @@ -621,7 +621,7 @@ static int get_remote_group(const char *key, const char *value, void *cb) static int update(int argc, const char **argv) { int i, result = 0; - struct path_list list = { NULL, 0, 0, 0 }; + struct string_list list = { NULL, 0, 0, 0 }; static const char *default_argv[] = { NULL, "default", NULL }; if (argc < 2) { @@ -639,20 +639,20 @@ static int update(int argc, const char **argv) result = for_each_remote(get_one_remote_for_update, &list); for (i = 0; i < list.nr; i++) - result |= fetch_remote(list.items[i].path); + result |= fetch_remote(list.items[i].string); /* all names were strdup()ed or strndup()ed */ - list.strdup_paths = 1; - path_list_clear(&list, 0); + list.strdup_strings = 1; + string_list_clear(&list, 0); return result; } static int get_one_entry(struct remote *remote, void *priv) { - struct path_list *list = priv; + struct string_list *list = priv; - path_list_append(remote->name, list)->util = remote->url_nr ? + string_list_append(remote->name, list)->util = remote->url_nr ? (void *)remote->url[0] : NULL; if (remote->url_nr > 1) warning("Remote %s has more than one URL", remote->name); @@ -662,16 +662,16 @@ static int get_one_entry(struct remote *remote, void *priv) static int show_all(void) { - struct path_list list = { NULL, 0, 0 }; + struct string_list list = { NULL, 0, 0 }; int result = for_each_remote(get_one_entry, &list); if (!result) { int i; - sort_path_list(&list); + sort_string_list(&list); for (i = 0; i < list.nr; i++) { - struct path_list_item *item = list.items + i; - printf("%s%s%s\n", item->path, + struct string_list_item *item = list.items + i; + printf("%s%s%s\n", item->string, verbose ? "\t" : "", verbose && item->util ? (const char *)item->util : ""); diff --git a/builtin-rerere.c b/builtin-rerere.c index 580580502c..dd4573fe8d 100644 --- a/builtin-rerere.c +++ b/builtin-rerere.c @@ -1,6 +1,6 @@ #include "builtin.h" #include "cache.h" -#include "path-list.h" +#include "string-list.h" #include "rerere.h" #include "xdiff/xdiff.h" #include "xdiff-interface.h" @@ -48,9 +48,9 @@ static int git_rerere_gc_config(const char *var, const char *value, void *cb) return 0; } -static void garbage_collect(struct path_list *rr) +static void garbage_collect(struct string_list *rr) { - struct path_list to_remove = { NULL, 0, 0, 1 }; + struct string_list to_remove = { NULL, 0, 0, 1 }; DIR *dir; struct dirent *e; int i, cutoff; @@ -69,11 +69,11 @@ static void garbage_collect(struct path_list *rr) cutoff = (has_resolution(name) ? cutoff_resolve : cutoff_noresolve); if (then < now - cutoff * 86400) - path_list_append(name, &to_remove); + string_list_append(name, &to_remove); } for (i = 0; i < to_remove.nr; i++) - unlink_rr_item(to_remove.items[i].path); - path_list_clear(&to_remove, 0); + unlink_rr_item(to_remove.items[i].string); + string_list_clear(&to_remove, 0); } static int outf(void *dummy, mmbuffer_t *ptr, int nbuf) @@ -111,7 +111,7 @@ static int diff_two(const char *file1, const char *label1, int cmd_rerere(int argc, const char **argv, const char *prefix) { - struct path_list merge_rr = { NULL, 0, 0, 1 }; + struct string_list merge_rr = { NULL, 0, 0, 1 }; int i, fd; if (argc < 2) @@ -132,16 +132,16 @@ int cmd_rerere(int argc, const char **argv, const char *prefix) garbage_collect(&merge_rr); else if (!strcmp(argv[1], "status")) for (i = 0; i < merge_rr.nr; i++) - printf("%s\n", merge_rr.items[i].path); + printf("%s\n", merge_rr.items[i].string); else if (!strcmp(argv[1], "diff")) for (i = 0; i < merge_rr.nr; i++) { - const char *path = merge_rr.items[i].path; + const char *path = merge_rr.items[i].string; const char *name = (const char *)merge_rr.items[i].util; diff_two(rr_path(name, "preimage"), path, path, path); } else usage(git_rerere_usage); - path_list_clear(&merge_rr, 1); + string_list_clear(&merge_rr, 1); return 0; } diff --git a/builtin-shortlog.c b/builtin-shortlog.c index 94c4723856..d03f14fdad 100644 --- a/builtin-shortlog.c +++ b/builtin-shortlog.c @@ -2,7 +2,7 @@ #include "cache.h" #include "commit.h" #include "diff.h" -#include "path-list.h" +#include "string-list.h" #include "revision.h" #include "utf8.h" #include "mailmap.h" @@ -18,8 +18,8 @@ static char const * const shortlog_usage[] = { static int compare_by_number(const void *a1, const void *a2) { - const struct path_list_item *i1 = a1, *i2 = a2; - const struct path_list *l1 = i1->util, *l2 = i2->util; + const struct string_list_item *i1 = a1, *i2 = a2; + const struct string_list *l1 = i1->util, *l2 = i2->util; if (l1->nr < l2->nr) return 1; @@ -35,8 +35,8 @@ static void insert_one_record(struct shortlog *log, { const char *dot3 = log->common_repo_prefix; char *buffer, *p; - struct path_list_item *item; - struct path_list *onelines; + struct string_list_item *item; + struct string_list *onelines; char namebuf[1024]; size_t len; const char *eol; @@ -69,9 +69,9 @@ static void insert_one_record(struct shortlog *log, } buffer = xstrdup(namebuf); - item = path_list_insert(buffer, &log->list); + item = string_list_insert(buffer, &log->list); if (item->util == NULL) - item->util = xcalloc(1, sizeof(struct path_list)); + item->util = xcalloc(1, sizeof(struct string_list)); else free(buffer); @@ -109,11 +109,11 @@ static void insert_one_record(struct shortlog *log, onelines->alloc = alloc_nr(onelines->nr); onelines->items = xrealloc(onelines->items, onelines->alloc - * sizeof(struct path_list_item)); + * sizeof(struct string_list_item)); } onelines->items[onelines->nr].util = NULL; - onelines->items[onelines->nr++].path = buffer; + onelines->items[onelines->nr++].string = buffer; } static void read_from_stdin(struct shortlog *log) @@ -231,7 +231,7 @@ void shortlog_init(struct shortlog *log) read_mailmap(&log->mailmap, ".mailmap", &log->common_repo_prefix); - log->list.strdup_paths = 1; + log->list.strdup_strings = 1; log->wrap = DEFAULT_WRAPLEN; log->in1 = DEFAULT_INDENT1; log->in2 = DEFAULT_INDENT2; @@ -299,17 +299,17 @@ void shortlog_output(struct shortlog *log) { int i, j; if (log->sort_by_number) - qsort(log->list.items, log->list.nr, sizeof(struct path_list_item), + qsort(log->list.items, log->list.nr, sizeof(struct string_list_item), compare_by_number); for (i = 0; i < log->list.nr; i++) { - struct path_list *onelines = log->list.items[i].util; + struct string_list *onelines = log->list.items[i].util; if (log->summary) { - printf("%6d\t%s\n", onelines->nr, log->list.items[i].path); + printf("%6d\t%s\n", onelines->nr, log->list.items[i].string); } else { - printf("%s (%d):\n", log->list.items[i].path, onelines->nr); + printf("%s (%d):\n", log->list.items[i].string, onelines->nr); for (j = onelines->nr - 1; j >= 0; j--) { - const char *msg = onelines->items[j].path; + const char *msg = onelines->items[j].string; if (log->wrap_lines) { int col = print_wrapped_text(msg, log->in1, log->in2, log->wrap); @@ -322,14 +322,14 @@ void shortlog_output(struct shortlog *log) putchar('\n'); } - onelines->strdup_paths = 1; - path_list_clear(onelines, 1); + onelines->strdup_strings = 1; + string_list_clear(onelines, 1); free(onelines); log->list.items[i].util = NULL; } - log->list.strdup_paths = 1; - path_list_clear(&log->list, 1); - log->mailmap.strdup_paths = 1; - path_list_clear(&log->mailmap, 1); + log->list.strdup_strings = 1; + string_list_clear(&log->list, 1); + log->mailmap.strdup_strings = 1; + string_list_clear(&log->mailmap, 1); } diff --git a/builtin-show-ref.c b/builtin-show-ref.c index a323633e29..add16004f1 100644 --- a/builtin-show-ref.c +++ b/builtin-show-ref.c @@ -3,7 +3,7 @@ #include "refs.h" #include "object.h" #include "tag.h" -#include "path-list.h" +#include "string-list.h" static const char show_ref_usage[] = "git show-ref [-q|--quiet] [--verify] [-h|--head] [-d|--dereference] [-s|--hash[=]] [--abbrev[=]] [--tags] [--heads] [--] [pattern*] < ref-list"; @@ -98,8 +98,8 @@ match: 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); + struct string_list *list = (struct string_list *)cbdata; + string_list_insert(refname, list); return 0; } @@ -114,7 +114,7 @@ static int add_existing(const char *refname, const unsigned char *sha1, int flag */ static int exclude_existing(const char *match) { - static struct path_list existing_refs = { NULL, 0, 0, 0 }; + static struct string_list existing_refs = { NULL, 0, 0, 0 }; char buf[1024]; int matchlen = match ? strlen(match) : 0; @@ -143,7 +143,7 @@ static int exclude_existing(const char *match) fprintf(stderr, "warning: ref '%s' ignored\n", ref); continue; } - if (!path_list_has_path(&existing_refs, ref)) { + if (!string_list_has_string(&existing_refs, ref)) { printf("%s\n", buf); } } diff --git a/diff-no-index.c b/diff-no-index.c index f6994cf5fb..7d68b7f1be 100644 --- a/diff-no-index.c +++ b/diff-no-index.c @@ -14,9 +14,9 @@ #include "revision.h" #include "log-tree.h" #include "builtin.h" -#include "path-list.h" +#include "string-list.h" -static int read_directory(const char *path, struct path_list *list) +static int read_directory(const char *path, struct string_list *list) { DIR *dir; struct dirent *e; @@ -26,7 +26,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(e->d_name, list); + string_list_insert(e->d_name, list); closedir(dir); return 0; @@ -60,13 +60,13 @@ static int queue_diff(struct diff_options *o, if (S_ISDIR(mode1) || S_ISDIR(mode2)) { char buffer1[PATH_MAX], buffer2[PATH_MAX]; - struct path_list p1 = {NULL, 0, 0, 1}, p2 = {NULL, 0, 0, 1}; + struct string_list p1 = {NULL, 0, 0, 1}, p2 = {NULL, 0, 0, 1}; int len1 = 0, len2 = 0, i1, i2, ret = 0; if (name1 && read_directory(name1, &p1)) return -1; if (name2 && read_directory(name2, &p2)) { - path_list_clear(&p1, 0); + string_list_clear(&p1, 0); return -1; } @@ -95,14 +95,14 @@ static int queue_diff(struct diff_options *o, else if (i2 == p2.nr) comp = -1; else - comp = strcmp(p1.items[i1].path, - p2.items[i2].path); + comp = strcmp(p1.items[i1].string, + p2.items[i2].string); if (comp > 0) n1 = NULL; else { n1 = buffer1; - strncpy(buffer1 + len1, p1.items[i1++].path, + strncpy(buffer1 + len1, p1.items[i1++].string, PATH_MAX - len1); } @@ -110,14 +110,14 @@ static int queue_diff(struct diff_options *o, n2 = NULL; else { n2 = buffer2; - strncpy(buffer2 + len2, p2.items[i2++].path, + strncpy(buffer2 + len2, p2.items[i2++].string, PATH_MAX - len2); } ret = queue_diff(o, n1, n2); } - path_list_clear(&p1, 0); - path_list_clear(&p2, 0); + string_list_clear(&p1, 0); + string_list_clear(&p2, 0); return ret; } else { diff --git a/mailmap.c b/mailmap.c index f0172552e4..88fc6f3946 100644 --- a/mailmap.c +++ b/mailmap.c @@ -1,8 +1,8 @@ #include "cache.h" -#include "path-list.h" +#include "string-list.h" #include "mailmap.h" -int read_mailmap(struct path_list *map, const char *filename, char **repo_abbrev) +int read_mailmap(struct string_list *map, const char *filename, char **repo_abbrev) { char buffer[1024]; FILE *f = fopen(filename, "r"); @@ -54,16 +54,16 @@ int read_mailmap(struct path_list *map, const char *filename, char **repo_abbrev for (i = 0; i < right_bracket - left_bracket - 1; i++) email[i] = tolower(left_bracket[i + 1]); email[right_bracket - left_bracket - 1] = '\0'; - path_list_insert(email, map)->util = name; + string_list_insert(email, map)->util = name; } fclose(f); return 0; } -int map_email(struct path_list *map, const char *email, char *name, int maxlen) +int map_email(struct string_list *map, const char *email, char *name, int maxlen) { char *p; - struct path_list_item *item; + struct string_list_item *item; char buf[1024], *mailbuf; int i; @@ -80,7 +80,7 @@ int map_email(struct path_list *map, const char *email, char *name, int maxlen) for (i = 0; i < p - email; i++) mailbuf[i] = tolower(email[i]); mailbuf[i] = 0; - item = path_list_lookup(mailbuf, map); + item = string_list_lookup(mailbuf, map); if (mailbuf != buf) free(mailbuf); if (item != NULL) { diff --git a/mailmap.h b/mailmap.h index 3503fd2727..6e48f83ced 100644 --- a/mailmap.h +++ b/mailmap.h @@ -1,7 +1,7 @@ #ifndef MAILMAP_H #define MAILMAP_H -int read_mailmap(struct path_list *map, const char *filename, char **repo_abbrev); -int map_email(struct path_list *mailmap, const char *email, char *name, int maxlen); +int read_mailmap(struct string_list *map, const char *filename, char **repo_abbrev); +int map_email(struct string_list *mailmap, const char *email, char *name, int maxlen); #endif diff --git a/path-list.c b/path-list.c deleted file mode 100644 index 92e5cf20fe..0000000000 --- a/path-list.c +++ /dev/null @@ -1,134 +0,0 @@ -#include "cache.h" -#include "path-list.h" - -/* if there is no exact match, point to the index where the entry could be - * inserted */ -static int get_entry_index(const struct path_list *list, const char *path, - int *exact_match) -{ - int left = -1, right = list->nr; - - while (left + 1 < right) { - int middle = (left + right) / 2; - int compare = strcmp(path, list->items[middle].path); - if (compare < 0) - right = middle; - else if (compare > 0) - left = middle; - else { - *exact_match = 1; - return middle; - } - } - - *exact_match = 0; - return right; -} - -/* returns -1-index if already exists */ -static int add_entry(struct path_list *list, const char *path) -{ - int exact_match; - int index = get_entry_index(list, path, &exact_match); - - if (exact_match) - return -1 - index; - - if (list->nr + 1 >= list->alloc) { - list->alloc += 32; - list->items = xrealloc(list->items, list->alloc - * sizeof(struct path_list_item)); - } - if (index < list->nr) - memmove(list->items + index + 1, list->items + index, - (list->nr - index) - * sizeof(struct path_list_item)); - list->items[index].path = list->strdup_paths ? - xstrdup(path) : (char *)path; - list->items[index].util = NULL; - list->nr++; - - return index; -} - -struct path_list_item *path_list_insert(const char *path, struct path_list *list) -{ - int index = add_entry(list, path); - - if (index < 0) - index = -1 - index; - - return list->items + index; -} - -int path_list_has_path(const struct path_list *list, const char *path) -{ - int exact_match; - get_entry_index(list, path, &exact_match); - return exact_match; -} - -struct path_list_item *path_list_lookup(const char *path, struct path_list *list) -{ - int exact_match, i = get_entry_index(list, path, &exact_match); - if (!exact_match) - return NULL; - return list->items + i; -} - -void path_list_clear(struct path_list *list, int free_util) -{ - if (list->items) { - int i; - if (list->strdup_paths) { - for (i = 0; i < list->nr; i++) - free(list->items[i].path); - } - if (free_util) { - for (i = 0; i < list->nr; i++) - free(list->items[i].util); - } - free(list->items); - } - list->items = NULL; - list->nr = list->alloc = 0; -} - -void print_path_list(const char *text, const struct path_list *p) -{ - int i; - if ( text ) - printf("%s\n", text); - for (i = 0; i < p->nr; i++) - printf("%s:%p\n", p->items[i].path, p->items[i].util); -} - -struct path_list_item *path_list_append(const char *path, struct path_list *list) -{ - ALLOC_GROW(list->items, list->nr + 1, list->alloc); - list->items[list->nr].path = - list->strdup_paths ? xstrdup(path) : (char *)path; - return list->items + list->nr++; -} - -static int cmp_items(const void *a, const void *b) -{ - const struct path_list_item *one = a; - const struct path_list_item *two = b; - return strcmp(one->path, two->path); -} - -void sort_path_list(struct path_list *list) -{ - qsort(list->items, list->nr, sizeof(*list->items), cmp_items); -} - -int unsorted_path_list_has_path(struct path_list *list, const char *path) -{ - int i; - for (i = 0; i < list->nr; i++) - if (!strcmp(path, list->items[i].path)) - return 1; - return 0; -} - diff --git a/path-list.h b/path-list.h deleted file mode 100644 index ca2cbbaa4d..0000000000 --- a/path-list.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef PATH_LIST_H -#define PATH_LIST_H - -struct path_list_item { - char *path; - void *util; -}; -struct path_list -{ - struct path_list_item *items; - unsigned int nr, alloc; - unsigned int strdup_paths:1; -}; - -void print_path_list(const char *text, const struct path_list *p); -void path_list_clear(struct path_list *list, int free_util); - -/* Use these functions only on sorted lists: */ -int path_list_has_path(const struct path_list *list, const char *path); -struct path_list_item *path_list_insert(const char *path, struct path_list *list); -struct path_list_item *path_list_lookup(const char *path, struct path_list *list); - -/* Use these functions only on unsorted lists: */ -struct path_list_item *path_list_append(const char *path, struct path_list *list); -void sort_path_list(struct path_list *list); -int unsorted_path_list_has_path(struct path_list *list, const char *path); - -#endif /* PATH_LIST_H */ diff --git a/pretty.c b/pretty.c index 628a5201c1..33ef34a411 100644 --- a/pretty.c +++ b/pretty.c @@ -3,7 +3,7 @@ #include "utf8.h" #include "diff.h" #include "revision.h" -#include "path-list.h" +#include "string-list.h" #include "mailmap.h" static char *user_format; @@ -292,7 +292,7 @@ static char *logmsg_reencode(const struct commit *commit, static int mailmap_name(struct strbuf *sb, const char *email) { - static struct path_list *mail_map; + static struct string_list *mail_map; char buffer[1024]; if (!mail_map) { diff --git a/reflog-walk.c b/reflog-walk.c index ee1456b45a..f751fdc8d8 100644 --- a/reflog-walk.c +++ b/reflog-walk.c @@ -3,7 +3,7 @@ #include "refs.h" #include "diff.h" #include "revision.h" -#include "path-list.h" +#include "string-list.h" #include "reflog-walk.h" struct complete_reflogs { @@ -127,7 +127,7 @@ struct commit_reflog { struct reflog_walk_info { struct commit_info_lifo reflogs; - struct path_list complete_reflogs; + struct string_list complete_reflogs; struct commit_reflog *last_commit_reflog; }; @@ -141,7 +141,7 @@ int add_reflog_for_walk(struct reflog_walk_info *info, { unsigned long timestamp = 0; int recno = -1; - struct path_list_item *item; + struct string_list_item *item; struct complete_reflogs *reflogs; char *branch, *at = strchr(name, '@'); struct commit_reflog *commit_reflog; @@ -161,7 +161,7 @@ int add_reflog_for_walk(struct reflog_walk_info *info, } else recno = 0; - item = path_list_lookup(branch, &info->complete_reflogs); + item = string_list_lookup(branch, &info->complete_reflogs); if (item) reflogs = item->util; else { @@ -189,7 +189,7 @@ int add_reflog_for_walk(struct reflog_walk_info *info, } if (!reflogs || reflogs->nr == 0) return -1; - path_list_insert(branch, &info->complete_reflogs)->util + string_list_insert(branch, &info->complete_reflogs)->util = reflogs; } diff --git a/rerere.c b/rerere.c index 0456aa6376..323e493daf 100644 --- a/rerere.c +++ b/rerere.c @@ -1,5 +1,5 @@ #include "cache.h" -#include "path-list.h" +#include "string-list.h" #include "rerere.h" #include "xdiff/xdiff.h" #include "xdiff-interface.h" @@ -23,7 +23,7 @@ static int has_resolution(const char *name) return !stat(rr_path(name, "postimage"), &st); } -static void read_rr(struct path_list *rr) +static void read_rr(struct string_list *rr) { unsigned char sha1[20]; char buf[PATH_MAX]; @@ -43,14 +43,14 @@ static void read_rr(struct path_list *rr) ; /* do nothing */ if (i == sizeof(buf)) die("filename too long"); - path_list_insert(buf, rr)->util = name; + string_list_insert(buf, rr)->util = name; } fclose(in); } static struct lock_file write_lock; -static int write_rr(struct path_list *rr, int out_fd) +static int write_rr(struct string_list *rr, int out_fd) { int i; for (i = 0; i < rr->nr; i++) { @@ -58,7 +58,7 @@ static int write_rr(struct path_list *rr, int out_fd) int length; if (!rr->items[i].util) continue; - path = rr->items[i].path; + path = rr->items[i].string; length = strlen(path) + 1; if (write_in_full(out_fd, rr->items[i].util, 40) != 40 || write_in_full(out_fd, "\t", 1) != 1 || @@ -154,7 +154,7 @@ static int handle_file(const char *path, return hunk_no; } -static int find_conflict(struct path_list *conflict) +static int find_conflict(struct string_list *conflict) { int i; if (read_cache() < 0) @@ -167,7 +167,7 @@ static int find_conflict(struct path_list *conflict) ce_same_name(e2, e3) && S_ISREG(e2->ce_mode) && S_ISREG(e3->ce_mode)) { - path_list_insert((const char *)e2->name, conflict); + string_list_insert((const char *)e2->name, conflict); i++; /* skip over both #2 and #3 */ } } @@ -208,7 +208,7 @@ static int merge(const char *name, const char *path) static struct lock_file index_lock; -static int update_paths(struct path_list *update) +static int update_paths(struct string_list *update) { int i; int fd = hold_locked_index(&index_lock, 0); @@ -218,8 +218,8 @@ static int update_paths(struct path_list *update) return -1; for (i = 0; i < update->nr; i++) { - struct path_list_item *item = &update->items[i]; - if (add_file_to_cache(item->path, ADD_CACHE_IGNORE_ERRORS)) + struct string_list_item *item = &update->items[i]; + if (add_file_to_cache(item->string, ADD_CACHE_IGNORE_ERRORS)) status = -1; } @@ -232,10 +232,10 @@ static int update_paths(struct path_list *update) return status; } -static int do_plain_rerere(struct path_list *rr, int fd) +static int do_plain_rerere(struct string_list *rr, int fd) { - struct path_list conflict = { NULL, 0, 0, 1 }; - struct path_list update = { NULL, 0, 0, 1 }; + struct string_list conflict = { NULL, 0, 0, 1 }; + struct string_list update = { NULL, 0, 0, 1 }; int i; find_conflict(&conflict); @@ -248,8 +248,8 @@ static int do_plain_rerere(struct path_list *rr, int fd) */ for (i = 0; i < conflict.nr; i++) { - const char *path = conflict.items[i].path; - if (!path_list_has_path(rr, path)) { + const char *path = conflict.items[i].string; + if (!string_list_has_string(rr, path)) { unsigned char sha1[20]; char *hex; int ret; @@ -257,7 +257,7 @@ static int do_plain_rerere(struct path_list *rr, int fd) if (ret < 1) continue; hex = xstrdup(sha1_to_hex(sha1)); - path_list_insert(path, rr)->util = hex; + string_list_insert(path, rr)->util = hex; if (mkdir(git_path("rr-cache/%s", hex), 0755)) continue;; handle_file(path, NULL, rr_path(hex, "preimage")); @@ -273,13 +273,13 @@ static int do_plain_rerere(struct path_list *rr, int fd) for (i = 0; i < rr->nr; i++) { int ret; - const char *path = rr->items[i].path; + const char *path = rr->items[i].string; const char *name = (const char *)rr->items[i].util; if (has_resolution(name)) { if (!merge(name, path)) { if (rerere_autoupdate) - path_list_insert(path, &update); + string_list_insert(path, &update); fprintf(stderr, "%s '%s' using previous resolution.\n", rerere_autoupdate @@ -337,7 +337,7 @@ static int is_rerere_enabled(void) return 1; } -int setup_rerere(struct path_list *merge_rr) +int setup_rerere(struct string_list *merge_rr) { int fd; @@ -353,7 +353,7 @@ int setup_rerere(struct path_list *merge_rr) int rerere(void) { - struct path_list merge_rr = { NULL, 0, 0, 1 }; + struct string_list merge_rr = { NULL, 0, 0, 1 }; int fd; fd = setup_rerere(&merge_rr); diff --git a/rerere.h b/rerere.h index 35b0fa86a3..f9b03862fe 100644 --- a/rerere.h +++ b/rerere.h @@ -1,9 +1,9 @@ #ifndef RERERE_H #define RERERE_H -#include "path-list.h" +#include "string-list.h" -extern int setup_rerere(struct path_list *); +extern int setup_rerere(struct string_list *); extern int rerere(void); #endif diff --git a/shortlog.h b/shortlog.h index 6608ee80b0..bc02cc29ef 100644 --- a/shortlog.h +++ b/shortlog.h @@ -1,10 +1,10 @@ #ifndef SHORTLOG_H #define SHORTLOG_H -#include "path-list.h" +#include "string-list.h" struct shortlog { - struct path_list list; + struct string_list list; int summary; int wrap_lines; int sort_by_number; @@ -15,7 +15,7 @@ struct shortlog { char *common_repo_prefix; int email; - struct path_list mailmap; + struct string_list mailmap; }; void shortlog_init(struct shortlog *log); diff --git a/string-list.c b/string-list.c new file mode 100644 index 0000000000..ddd83c8c76 --- /dev/null +++ b/string-list.c @@ -0,0 +1,134 @@ +#include "cache.h" +#include "string-list.h" + +/* if there is no exact match, point to the index where the entry could be + * inserted */ +static int get_entry_index(const struct string_list *list, const char *string, + int *exact_match) +{ + int left = -1, right = list->nr; + + while (left + 1 < right) { + int middle = (left + right) / 2; + int compare = strcmp(string, list->items[middle].string); + if (compare < 0) + right = middle; + else if (compare > 0) + left = middle; + else { + *exact_match = 1; + return middle; + } + } + + *exact_match = 0; + return right; +} + +/* returns -1-index if already exists */ +static int add_entry(struct string_list *list, const char *string) +{ + int exact_match; + int index = get_entry_index(list, string, &exact_match); + + if (exact_match) + return -1 - index; + + if (list->nr + 1 >= list->alloc) { + list->alloc += 32; + list->items = xrealloc(list->items, list->alloc + * sizeof(struct string_list_item)); + } + if (index < list->nr) + memmove(list->items + index + 1, list->items + index, + (list->nr - index) + * sizeof(struct string_list_item)); + list->items[index].string = list->strdup_strings ? + xstrdup(string) : (char *)string; + list->items[index].util = NULL; + list->nr++; + + return index; +} + +struct string_list_item *string_list_insert(const char *string, struct string_list *list) +{ + int index = add_entry(list, string); + + if (index < 0) + index = -1 - index; + + return list->items + index; +} + +int string_list_has_string(const struct string_list *list, const char *string) +{ + int exact_match; + get_entry_index(list, string, &exact_match); + return exact_match; +} + +struct string_list_item *string_list_lookup(const char *string, struct string_list *list) +{ + int exact_match, i = get_entry_index(list, string, &exact_match); + if (!exact_match) + return NULL; + return list->items + i; +} + +void string_list_clear(struct string_list *list, int free_util) +{ + if (list->items) { + int i; + if (list->strdup_strings) { + for (i = 0; i < list->nr; i++) + free(list->items[i].string); + } + if (free_util) { + for (i = 0; i < list->nr; i++) + free(list->items[i].util); + } + free(list->items); + } + list->items = NULL; + list->nr = list->alloc = 0; +} + +void print_string_list(const char *text, const struct string_list *p) +{ + int i; + if ( text ) + printf("%s\n", text); + for (i = 0; i < p->nr; i++) + printf("%s:%p\n", p->items[i].string, p->items[i].util); +} + +struct string_list_item *string_list_append(const char *string, struct string_list *list) +{ + ALLOC_GROW(list->items, list->nr + 1, list->alloc); + list->items[list->nr].string = + list->strdup_strings ? xstrdup(string) : (char *)string; + return list->items + list->nr++; +} + +static int cmp_items(const void *a, const void *b) +{ + const struct string_list_item *one = a; + const struct string_list_item *two = b; + return strcmp(one->string, two->string); +} + +void sort_string_list(struct string_list *list) +{ + qsort(list->items, list->nr, sizeof(*list->items), cmp_items); +} + +int unsorted_string_list_has_string(struct string_list *list, const char *string) +{ + int i; + for (i = 0; i < list->nr; i++) + if (!strcmp(string, list->items[i].string)) + return 1; + return 0; +} + diff --git a/string-list.h b/string-list.h new file mode 100644 index 0000000000..4d6a7051fe --- /dev/null +++ b/string-list.h @@ -0,0 +1,28 @@ +#ifndef PATH_LIST_H +#define PATH_LIST_H + +struct string_list_item { + char *string; + void *util; +}; +struct string_list +{ + struct string_list_item *items; + unsigned int nr, alloc; + unsigned int strdup_strings:1; +}; + +void print_string_list(const char *text, const struct string_list *p); +void string_list_clear(struct string_list *list, int free_util); + +/* Use these functions only on sorted lists: */ +int string_list_has_string(const struct string_list *list, const char *string); +struct string_list_item *string_list_insert(const char *string, struct string_list *list); +struct string_list_item *string_list_lookup(const char *string, struct string_list *list); + +/* Use these functions only on unsorted lists: */ +struct string_list_item *string_list_append(const char *string, struct string_list *list); +void sort_string_list(struct string_list *list); +int unsorted_string_list_has_string(struct string_list *list, const char *string); + +#endif /* PATH_LIST_H */ From e57c817d9f8f67d93c9fdea30939c52a2ab44fc4 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Mon, 21 Jul 2008 13:34:06 -0500 Subject: [PATCH 04/14] git-diff(1): "--c" -> "--cc" typo fix git diff does not take a --c option. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- Documentation/diff-generate-patch.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/diff-generate-patch.txt b/Documentation/diff-generate-patch.txt index 029c5f2b82..517e1eba3c 100644 --- a/Documentation/diff-generate-patch.txt +++ b/Documentation/diff-generate-patch.txt @@ -96,7 +96,7 @@ index fabadb8,cc95eb0..4866510 + or like this (when '--cc' option is used): - diff --c file + diff --cc file 2. It is followed by one or more extended header lines (this example shows a merge with two parents): From 107623239a0514052ca6431eca18405c76d9d658 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 21 Jul 2008 19:41:17 -0700 Subject: [PATCH 05/14] Revert "make git-status use a pager" This reverts commit c8af1de9cfa0a5678ae766777e0f905e60b69fda. The change was immensely unpopular, and poeple who would really want to page can use pager.status configuration. --- git.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git.c b/git.c index 74ea0e6cc5..1bfd271a71 100644 --- a/git.c +++ b/git.c @@ -341,7 +341,7 @@ static void handle_internal_command(int argc, const char **argv) { "shortlog", cmd_shortlog, USE_PAGER }, { "show-branch", cmd_show_branch, RUN_SETUP }, { "show", cmd_show, RUN_SETUP | USE_PAGER }, - { "status", cmd_status, RUN_SETUP | NEED_WORK_TREE | USE_PAGER }, + { "status", cmd_status, RUN_SETUP | NEED_WORK_TREE }, { "stripspace", cmd_stripspace }, { "symbolic-ref", cmd_symbolic_ref, RUN_SETUP }, { "tag", cmd_tag, RUN_SETUP }, From 75e1645fbe5e0309fbab8c2bfeaebe2c505e679d Mon Sep 17 00:00:00 2001 From: Olivier Marin Date: Mon, 21 Jul 2008 16:12:20 +0200 Subject: [PATCH 06/14] git-am: remove dash from help message Signed-off-by: Olivier Marin Signed-off-by: Junio C Hamano --- git-am.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-am.sh b/git-am.sh index 9bf12feeb2..fcbffb2ba1 100755 --- a/git-am.sh +++ b/git-am.sh @@ -44,7 +44,7 @@ stop_here_user_resolve () { printf '%s\n' "$resolvemsg" stop_here $1 fi - cmdline=$(basename $0) + cmdline="git am" if test '' != "$interactive" then cmdline="$cmdline -i" From 0d4ede9f5493f0e15fb4f799e6a4a25e36c49fd2 Mon Sep 17 00:00:00 2001 From: "Philippe Bruhat (BooK)" Date: Mon, 21 Jul 2008 15:34:29 +0200 Subject: [PATCH 07/14] mailinfo: better parse email adresses containg parentheses MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When using git-rebase, author fields containing a ')' at the last position had the close-parens character removed; the removal should be done only when it is of this form: user@host (User Name) i.e. the remainder after stripping the e-mail address part is enclosed in a parentheses pair as a whole, not for addresses like this: User Name (me) Signed-off-by: Philippe Bruhat (BooK) Acked-by: Lukas Sandström Signed-off-by: Junio C Hamano --- builtin-mailinfo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c index b99a5b6f96..f974b9df96 100644 --- a/builtin-mailinfo.c +++ b/builtin-mailinfo.c @@ -115,10 +115,10 @@ static void handle_from(const struct strbuf *from) * the () pair at the end. */ strbuf_trim(&f); - if (f.buf[0] == '(') - strbuf_remove(&name, 0, 1); - if (f.len && f.buf[f.len - 1] == ')') + if (f.buf[0] == '(' && f.len && f.buf[f.len - 1] == ')') { + strbuf_remove(&f, 0, 1); strbuf_setlen(&f, f.len - 1); + } get_sane_name(&name, &f, &email); strbuf_release(&f); From d5d745f90b929310f3893bb8b3766cc1745140c8 Mon Sep 17 00:00:00 2001 From: Olivier Marin Date: Mon, 21 Jul 2008 20:30:36 +0200 Subject: [PATCH 08/14] parse-options: fix segmentation fault when a required value is missing p->argc represent the number of arguments that have not been parsed yet, _including_ the one we are currently parsing. If it is not greater than one then there is no more argument. Signed-off-by: Olivier Marin Acked-by: Pierre Habouzit Signed-off-by: Junio C Hamano --- parse-options.c | 2 +- t/t0040-parse-options.sh | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/parse-options.c b/parse-options.c index 987b015719..71a7acf4e2 100644 --- a/parse-options.c +++ b/parse-options.c @@ -22,7 +22,7 @@ static int get_arg(struct parse_opt_ctx_t *p, const struct option *opt, p->opt = NULL; } else if (p->argc == 1 && (opt->flags & PARSE_OPT_LASTARG_DEFAULT)) { *arg = (const char *)opt->defval; - } else if (p->argc) { + } else if (p->argc > 1) { p->argc--; *arg = *++p->argv; } else diff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh index 6309aed451..03dbe00102 100755 --- a/t/t0040-parse-options.sh +++ b/t/t0040-parse-options.sh @@ -78,6 +78,13 @@ test_expect_success 'long options' ' test_cmp expect output ' +test_expect_success 'missing required value' ' + test-parse-options -s; + test $? = 129 && + test-parse-options --string; + test $? = 129 +' + cat > expect << EOF boolean: 1 integer: 13 From c79cc2e59672fa03985f27ecdbea84e06ea5358f Mon Sep 17 00:00:00 2001 From: Nikolaj Schumacher Date: Mon, 30 Jun 2008 12:08:16 +0200 Subject: [PATCH 09/14] Don't cut off last character of commit descriptions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This should have been part of 24a2293 (git-blame.el: show the when, who and what in the minibuffer., 2008-02-12), that changed from using --pretty=oneline to --pretty=format:... without terminating newline. Acked-by: David Kågedal Signed-off-by: Junio C Hamano --- contrib/emacs/git-blame.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/emacs/git-blame.el b/contrib/emacs/git-blame.el index 9f92cd250b..4fa70c5ad4 100644 --- a/contrib/emacs/git-blame.el +++ b/contrib/emacs/git-blame.el @@ -381,7 +381,7 @@ See also function `git-blame-mode'." "log" "-1" (concat "--pretty=" git-blame-log-oneline-format) hash) - (buffer-substring (point-min) (1- (point-max))))) + (buffer-substring (point-min) (point-max)))) (defvar git-blame-last-identification nil) (make-variable-buffer-local 'git-blame-last-identification) From ac2e28c0a43ced3837fbbcf66fd693244b6c6693 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 20 Jul 2008 01:33:46 -0700 Subject: [PATCH 10/14] tests: do not rely on external "patch" Some of our tests assumed a working "patch" command to produce expected results when checking "git-apply", but some systems have broken "patch". We can compare our output with expected output that is precomputed instead to sidestep this issue. Signed-off-by: Junio C Hamano --- t/t4109-apply-multifrag.sh | 59 +++++++++-------------- t/t4109/expect-1 | 31 ++++++++++++ t/t4109/expect-2 | 23 +++++++++ t/t4109/expect-3 | 24 ++++++++++ t/t4110-apply-scan.sh | 96 ++++---------------------------------- t/t4110/expect | 20 ++++++++ t/t4110/patch1.patch | 17 +++++++ t/t4110/patch2.patch | 11 +++++ t/t4110/patch3.patch | 14 ++++++ t/t4110/patch4.patch | 11 +++++ t/t4110/patch5.patch | 11 +++++ 11 files changed, 192 insertions(+), 125 deletions(-) create mode 100644 t/t4109/expect-1 create mode 100644 t/t4109/expect-2 create mode 100644 t/t4109/expect-3 create mode 100644 t/t4110/expect create mode 100644 t/t4110/patch1.patch create mode 100644 t/t4110/patch2.patch create mode 100644 t/t4110/patch3.patch create mode 100644 t/t4110/patch4.patch create mode 100644 t/t4110/patch5.patch diff --git a/t/t4109-apply-multifrag.sh b/t/t4109-apply-multifrag.sh index ff5fdf35f9..ac58083fe2 100755 --- a/t/t4109-apply-multifrag.sh +++ b/t/t4109-apply-multifrag.sh @@ -4,49 +4,32 @@ # Copyright (c) 2005 Robert Fitzsimons # -test_description='git apply test patches with multiple fragments. +test_description='git apply test patches with multiple fragments.' -' . ./test-lib.sh -cp ../t4109/patch1.patch . -cp ../t4109/patch2.patch . -cp ../t4109/patch3.patch . -cp ../t4109/patch4.patch . +cp "$TEST_DIRECTORY/t4109/patch1.patch" . +cp "$TEST_DIRECTORY/t4109/patch2.patch" . +cp "$TEST_DIRECTORY/t4109/patch3.patch" . +cp "$TEST_DIRECTORY/t4109/patch4.patch" . -test_expect_success "S = git apply (1)" \ - 'git apply patch1.patch patch2.patch' +test_expect_success 'git apply (1)' ' + git apply patch1.patch patch2.patch && + test_cmp "$TEST_DIRECTORY/t4109/expect-1" main.c +' +rm -f main.c + +test_expect_success 'git apply (2)' ' + git apply patch1.patch patch2.patch patch3.patch && + test_cmp "$TEST_DIRECTORY/t4109/expect-2" main.c +' +rm -f main.c + +test_expect_success 'git apply (3)' ' + git apply patch1.patch patch4.patch && + test_cmp "$TEST_DIRECTORY/t4109/expect-3" main.c +' mv main.c main.c.git -test_expect_success "S = patch (1)" \ - 'cat patch1.patch patch2.patch | patch -p1' - -test_expect_success "S = cmp (1)" \ - 'cmp main.c.git main.c' - -rm -f main.c main.c.git - -test_expect_success "S = git apply (2)" \ - 'git apply patch1.patch patch2.patch patch3.patch' -mv main.c main.c.git - -test_expect_success "S = patch (2)" \ - 'cat patch1.patch patch2.patch patch3.patch | patch -p1' - -test_expect_success "S = cmp (2)" \ - 'cmp main.c.git main.c' - -rm -f main.c main.c.git - -test_expect_success "S = git apply (3)" \ - 'git apply patch1.patch patch4.patch' -mv main.c main.c.git - -test_expect_success "S = patch (3)" \ - 'cat patch1.patch patch4.patch | patch -p1' - -test_expect_success "S = cmp (3)" \ - 'cmp main.c.git main.c' - test_done diff --git a/t/t4109/expect-1 b/t/t4109/expect-1 new file mode 100644 index 0000000000..1db5ff1050 --- /dev/null +++ b/t/t4109/expect-1 @@ -0,0 +1,31 @@ +#include +#include + +int func(int num); +void print_int(int num); +void print_ln(); + +int main() { + int i; + + for (i = 0; i < 10; i++) { + print_int(func(i)); + } + + print_ln(); + + return 0; +} + +int func(int num) { + return num * num; +} + +void print_int(int num) { + printf("%d", num); +} + +void print_ln() { + printf("\n"); +} + diff --git a/t/t4109/expect-2 b/t/t4109/expect-2 new file mode 100644 index 0000000000..bc52924112 --- /dev/null +++ b/t/t4109/expect-2 @@ -0,0 +1,23 @@ +#include + +int func(int num); +void print_int(int num); + +int main() { + int i; + + for (i = 0; i < 10; i++) { + print_int(func(i)); + } + + return 0; +} + +int func(int num) { + return num * num; +} + +void print_int(int num) { + printf("%d", num); +} + diff --git a/t/t4109/expect-3 b/t/t4109/expect-3 new file mode 100644 index 0000000000..cd2a475feb --- /dev/null +++ b/t/t4109/expect-3 @@ -0,0 +1,24 @@ +#include + +int func(int num); +int func2(int num); + +int main() { + int i; + + for (i = 0; i < 10; i++) { + printf("%d", func(i)); + printf("%d", func3(i)); + } + + return 0; +} + +int func(int num) { + return num * num; +} + +int func2(int num) { + return num * num * num; +} + diff --git a/t/t4110-apply-scan.sh b/t/t4110-apply-scan.sh index db60652a37..09f58112e0 100755 --- a/t/t4110-apply-scan.sh +++ b/t/t4110-apply-scan.sh @@ -9,92 +9,14 @@ test_description='git apply test for patches which require scanning forwards and ' . ./test-lib.sh -# setup - -cat > patch1.patch <<\EOF -diff --git a/new.txt b/new.txt -new file mode 100644 ---- /dev/null -+++ b/new.txt -@@ -0,0 +1,12 @@ -+a1 -+a11 -+a111 -+a1111 -+b1 -+b11 -+b111 -+b1111 -+c1 -+c11 -+c111 -+c1111 -EOF -cat > patch2.patch <<\EOF -diff --git a/new.txt b/new.txt ---- a/new.txt -+++ b/new.txt -@@ -1,7 +1,3 @@ --a1 --a11 --a111 --a1111 - b1 - b11 - b111 -EOF -cat > patch3.patch <<\EOF -diff --git a/new.txt b/new.txt ---- a/new.txt -+++ b/new.txt -@@ -6,6 +6,10 @@ - b11 - b111 - b1111 -+b2 -+b22 -+b222 -+b2222 - c1 - c11 - c111 -EOF -cat > patch4.patch <<\EOF -diff --git a/new.txt b/new.txt ---- a/new.txt -+++ b/new.txt -@@ -1,3 +1,7 @@ -+a1 -+a11 -+a111 -+a1111 - b1 - b11 - b111 -EOF -cat > patch5.patch <<\EOF -diff --git a/new.txt b/new.txt ---- a/new.txt -+++ b/new.txt -@@ -10,3 +10,7 @@ - c11 - c111 - c1111 -+c2 -+c22 -+c222 -+c2222 -EOF - -test_expect_success "S = git apply scan" \ - 'git apply patch1.patch patch2.patch patch3.patch patch4.patch patch5.patch' -mv new.txt apply.txt - -test_expect_success "S = patch scan" \ - 'cat patch1.patch patch2.patch patch3.patch patch4.patch patch5.patch | patch' -mv new.txt patch.txt - -test_expect_success "S = cmp" \ - 'cmp apply.txt patch.txt' +test_expect_success 'git apply scan' ' + git apply \ + "$TEST_DIRECTORY/t4110/patch1.patch" \ + "$TEST_DIRECTORY/t4110/patch2.patch" \ + "$TEST_DIRECTORY/t4110/patch3.patch" \ + "$TEST_DIRECTORY/t4110/patch4.patch" \ + "$TEST_DIRECTORY/t4110/patch5.patch" && + test_cmp new.txt "$TEST_DIRECTORY/t4110/expect" +' test_done diff --git a/t/t4110/expect b/t/t4110/expect new file mode 100644 index 0000000000..87cc493ec8 --- /dev/null +++ b/t/t4110/expect @@ -0,0 +1,20 @@ +a1 +a11 +a111 +a1111 +b1 +b11 +b111 +b1111 +b2 +b22 +b222 +b2222 +c1 +c11 +c111 +c1111 +c2 +c22 +c222 +c2222 diff --git a/t/t4110/patch1.patch b/t/t4110/patch1.patch new file mode 100644 index 0000000000..56139080dc --- /dev/null +++ b/t/t4110/patch1.patch @@ -0,0 +1,17 @@ +diff --git a/new.txt b/new.txt +new file mode 100644 +--- /dev/null ++++ b/new.txt +@@ -0,0 +1,12 @@ ++a1 ++a11 ++a111 ++a1111 ++b1 ++b11 ++b111 ++b1111 ++c1 ++c11 ++c111 ++c1111 diff --git a/t/t4110/patch2.patch b/t/t4110/patch2.patch new file mode 100644 index 0000000000..04974247ec --- /dev/null +++ b/t/t4110/patch2.patch @@ -0,0 +1,11 @@ +diff --git a/new.txt b/new.txt +--- a/new.txt ++++ b/new.txt +@@ -1,7 +1,3 @@ +-a1 +-a11 +-a111 +-a1111 + b1 + b11 + b111 diff --git a/t/t4110/patch3.patch b/t/t4110/patch3.patch new file mode 100644 index 0000000000..26bd4427f8 --- /dev/null +++ b/t/t4110/patch3.patch @@ -0,0 +1,14 @@ +diff --git a/new.txt b/new.txt +--- a/new.txt ++++ b/new.txt +@@ -6,6 +6,10 @@ + b11 + b111 + b1111 ++b2 ++b22 ++b222 ++b2222 + c1 + c11 + c111 diff --git a/t/t4110/patch4.patch b/t/t4110/patch4.patch new file mode 100644 index 0000000000..9ffb9c2d7e --- /dev/null +++ b/t/t4110/patch4.patch @@ -0,0 +1,11 @@ +diff --git a/new.txt b/new.txt +--- a/new.txt ++++ b/new.txt +@@ -1,3 +1,7 @@ ++a1 ++a11 ++a111 ++a1111 + b1 + b11 + b111 diff --git a/t/t4110/patch5.patch b/t/t4110/patch5.patch new file mode 100644 index 0000000000..c5ac6914f9 --- /dev/null +++ b/t/t4110/patch5.patch @@ -0,0 +1,11 @@ +diff --git a/new.txt b/new.txt +--- a/new.txt ++++ b/new.txt +@@ -10,3 +10,7 @@ + c11 + c111 + c1111 ++c2 ++c22 ++c222 ++c2222 From 1719b5e446f54e4196903ae6ed5f8867a5755bf6 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 21 Jul 2008 18:10:47 +0200 Subject: [PATCH 11/14] builtin-merge: give a proper error message for invalid strategies in config 'git merge -s foobar' diagnosed invalid "foobar" strategy and errored out with a message, but foobar in pull.twohead or pull.octopus was just silently ignored. This makes invalid strategy both on the command line and in the configuration file to trigger the same error. Signed-off-by: Miklos Vajna Signed-off-by: Junio C Hamano --- builtin-merge.c | 37 ++++++++++++------------------------ t/t7601-merge-pull-config.sh | 12 ++++++++++++ 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/builtin-merge.c b/builtin-merge.c index e97c79e60c..0fd7985a11 100644 --- a/builtin-merge.c +++ b/builtin-merge.c @@ -77,6 +77,7 @@ static int option_parse_message(const struct option *opt, static struct strategy *get_strategy(const char *name) { int i; + struct strbuf err; if (!name) return NULL; @@ -84,7 +85,13 @@ static struct strategy *get_strategy(const char *name) for (i = 0; i < ARRAY_SIZE(all_strategy); i++) if (!strcmp(name, all_strategy[i].name)) return &all_strategy[i]; - return NULL; + + strbuf_init(&err, 0); + for (i = 0; i < ARRAY_SIZE(all_strategy); i++) + strbuf_addf(&err, " %s", all_strategy[i].name); + fprintf(stderr, "Could not find merge strategy '%s'.\n", name); + fprintf(stderr, "Available strategies are:%s.\n", err.buf); + exit(1); } static void append_strategy(struct strategy *s) @@ -96,25 +103,10 @@ static void append_strategy(struct strategy *s) static int option_parse_strategy(const struct option *opt, const char *name, int unset) { - int i; - struct strategy *s; - if (unset) return 0; - s = get_strategy(name); - - if (s) - append_strategy(s); - else { - struct strbuf err; - strbuf_init(&err, 0); - for (i = 0; i < ARRAY_SIZE(all_strategy); i++) - strbuf_addf(&err, " %s", all_strategy[i].name); - fprintf(stderr, "Could not find merge strategy '%s'.\n", name); - fprintf(stderr, "Available strategies are:%s.\n", err.buf); - exit(1); - } + append_strategy(get_strategy(name)); return 0; } @@ -643,14 +635,9 @@ static void add_strategies(const char *string, unsigned attr) memset(&list, 0, sizeof(list)); split_merge_strategies(string, &list, &list_nr, &list_alloc); - if (list != NULL) { - for (i = 0; i < list_nr; i++) { - struct strategy *s; - - s = get_strategy(list[i].name); - if (s) - append_strategy(s); - } + if (list) { + for (i = 0; i < list_nr; i++) + append_strategy(get_strategy(list[i].name)); return; } for (i = 0; i < ARRAY_SIZE(all_strategy); i++) diff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh index 95b4d71c51..6b9f6388c7 100755 --- a/t/t7601-merge-pull-config.sh +++ b/t/t7601-merge-pull-config.sh @@ -126,4 +126,16 @@ test_expect_success 'merge picks up the best result' ' test $auto_count != $resolve_count ' +test_expect_success 'merge errors out on invalid strategy' ' + git config pull.twohead "foobar" && + git reset --hard c5 && + test_must_fail git merge c6 +' + +test_expect_success 'merge errors out on invalid strategy' ' + git config --unset-all pull.twohead && + git reset --hard c5 && + test_must_fail git merge -s "resolve recursive" c6 +' + test_done From 5d2299de2d9ff01318bc02ea8c7fbf8d3a699ae0 Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Mon, 21 Jul 2008 22:32:53 -0700 Subject: [PATCH 12/14] builtin-merge: add missing structure initialization The parameter that is eventually passed to read_directory() to scan the working tree should be properly initialized. Signed-off-by: Pierre Habouzit Signed-off-by: Junio C Hamano --- builtin-merge.c | 1 + 1 file changed, 1 insertion(+) diff --git a/builtin-merge.c b/builtin-merge.c index 0fd7985a11..8825dcf8d9 100644 --- a/builtin-merge.c +++ b/builtin-merge.c @@ -572,6 +572,7 @@ static int checkout_fast_forward(unsigned char *head, unsigned char *remote) memset(&trees, 0, sizeof(trees)); memset(&opts, 0, sizeof(opts)); memset(&t, 0, sizeof(t)); + memset(&dir, 0, sizeof(dir)); dir.show_ignored = 1; dir.exclude_per_dir = ".gitignore"; opts.dir = &dir; From d1f63a37caae19314bbd55c9fe3554d2e53537e7 Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Mon, 21 Jul 2008 20:15:59 +0200 Subject: [PATCH 13/14] git-submodule: move ill placed shift. When running git submodule update -i, the "-i" is shifted before recursing into cmd_init and then again outside of the loop. This causes some /bin/sh to complain about shifting when there are no arguments left (and would discard anything written after -i too). Signed-off-by: Pierre Habouzit Signed-off-by: Junio C Hamano --- git-submodule.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-submodule.sh b/git-submodule.sh index 9228f56bee..b40f876a2c 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -264,6 +264,7 @@ cmd_update() do case "$1" in -q|--quiet) + shift quiet=1 ;; -i|--init) @@ -281,7 +282,6 @@ cmd_update() break ;; esac - shift done git ls-files --stage -- "$@" | grep '^160000 ' | From 95f8ebbfc7997b3114d4f09360501324905c4e6d Mon Sep 17 00:00:00 2001 From: Olivier Marin Date: Mon, 21 Jul 2008 15:39:06 +0200 Subject: [PATCH 14/14] git am --skip: clean the index while preserving local changes In 3-way merge, "am" will let the index with unmerged path waiting for us to resolve conflicts and continue. But if we want to --skip instead, "am" refuses to continue because of the dirty index. With this patch, "am" will clean the index without touching files locally modified, before continuing. Signed-off-by: Olivier Marin Signed-off-by: Junio C Hamano --- git-am.sh | 12 +++++++++--- t/t4151-am-abort.sh | 11 +++++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/git-am.sh b/git-am.sh index fcbffb2ba1..7864b5f588 100755 --- a/git-am.sh +++ b/git-am.sh @@ -202,8 +202,15 @@ then die "previous rebase directory $dotest still exists but mbox given." resume=yes - case "$abort" in - t) + case "$skip,$abort" in + t,) + git rerere clear + git read-tree --reset -u HEAD HEAD + orig_head=$(cat "$GIT_DIR/ORIG_HEAD") + git reset HEAD + git update-ref ORIG_HEAD $orig_head + ;; + ,t) git rerere clear git read-tree --reset -u HEAD ORIG_HEAD git reset ORIG_HEAD @@ -297,7 +304,6 @@ last=`cat "$dotest/last"` this=`cat "$dotest/next"` if test "$skip" = t then - git rerere clear this=`expr "$this" + 1` resume= fi diff --git a/t/t4151-am-abort.sh b/t/t4151-am-abort.sh index dda7e2c28e..249093b6d0 100755 --- a/t/t4151-am-abort.sh +++ b/t/t4151-am-abort.sh @@ -14,7 +14,7 @@ test_expect_success setup ' git add file-1 file-2 && git commit -m initial && git tag initial && - for i in 2 3 4 5 + for i in 2 3 4 5 6 do echo $i >>file-1 && test_tick && @@ -32,7 +32,7 @@ do git reset --hard initial && cp file-2-expect file-2 && - test_must_fail git am$with3 000[124]-*.patch && + test_must_fail git am$with3 000[1245]-*.patch && git log --pretty=tformat:%s >actual && for i in 3 2 initial do @@ -41,6 +41,13 @@ do test_cmp expect actual ' + test_expect_success "am$with3 --skip continue after failed am$with3" ' + test_must_fail git-am$with3 --skip >output && + test "$(grep "^Applying" output)" = "Applying 6" && + test_cmp file-2-expect file-2 && + test ! -f .git/rr-cache/MERGE_RR + ' + test_expect_success "am --abort goes back after failed am$with3" ' git-am --abort && git rev-parse HEAD >actual &&