{"thread":{"id":"43921","subject":"[RFC PATCH] completion: support excluding refs","startedAt":"2016-08-24T08:43:36Z","lastAt":"2016-08-24T16:56:06Z","messageCount":2,"participants":["Chris Packham","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"300034","messageId":"20160824084152.2857-1-judge.packham@gmail.com","threadId":"43921","inReplyTo":null,"subject":"[RFC PATCH] completion: support excluding refs","fromName":"Chris Packham","fromEmail":"judge.packham@gmail.com","sentAt":"2016-08-24T08:41:52Z","receivedAt":"2016-08-24T08:43:36Z","isPatch":true,"sender":{"key":"judge.packham@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155667?v=4"},"body":"Allow completion of refs with a ^ prefix. This allows completion of\ncommands like 'git log HEAD ^origin/master'.\n\nSigned-off-by: Chris Packham <judge.packham@gmail.com>\n---\nI often find myself using variations of 'git log HEAD ^origin/master' to\nsee commits that I have locally that have not been pushed. It is also\nuseful when reviewing changes before integrating them e.g. 'git fetch\n...; git log FETCH_HEAD ^origin/master'.\n\n contrib/completion/git-completion.bash | 7 ++++---\n 1 file changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 9c8f738..21016bf 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -338,7 +338,7 @@ __git_tags ()\n __git_refs ()\n {\n \tlocal i hash dir=\"$(__gitdir \"${1-}\")\" track=\"${2-}\"\n-\tlocal format refs\n+\tlocal format refs pfx\n \tif [ -d \"$dir\" ]; then\n \t\tcase \"$cur\" in\n \t\trefs|refs/*)\n@@ -347,14 +347,15 @@ __git_refs ()\n \t\t\ttrack=\"\"\n \t\t\t;;\n \t\t*)\n+\t\t\t[[ \"$cur\" == ^* ]] && pfx=\"^\"\n \t\t\tfor i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do\n-\t\t\t\tif [ -e \"$dir/$i\" ]; then echo $i; fi\n+\t\t\t\tif [ -e \"$dir/$i\" ]; then echo $pfx$i; fi\n \t\t\tdone\n \t\t\tformat=\"refname:short\"\n \t\t\trefs=\"refs/tags refs/heads refs/remotes\"\n \t\t\t;;\n \t\tesac\n-\t\tgit --git-dir=\"$dir\" for-each-ref --format=\"%($format)\" \\\n+\t\tgit --git-dir=\"$dir\" for-each-ref --format=\"$pfx%($format)\" \\\n \t\t\t$refs\n \t\tif [ -n \"$track\" ]; then\n \t\t\t# employ the heuristic used by git checkout\n-- \n2.9.2.518.ged577c6.dirty\n\n"},{"id":"300080","messageId":"xmqqy43mqfcp.fsf@gitster.mtv.corp.google.com","threadId":"43921","inReplyTo":"20160824084152.2857-1-judge.packham@gmail.com","subject":"Re: [RFC PATCH] completion: support excluding refs","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-08-24T16:52:22Z","receivedAt":"2016-08-24T16:56:06Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Chris Packham <judge.packham@gmail.com> writes:\n\n> Allow completion of refs with a ^ prefix. This allows completion of\n> commands like 'git log HEAD ^origin/master'.\n> ...\n> +\t\t\t[[ \"$cur\" == ^* ]] && pfx=\"^\"\n>  \t\t\tfor i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do\n> -\t\t\t\tif [ -e \"$dir/$i\" ]; then echo $i; fi\n> +\t\t\t\tif [ -e \"$dir/$i\" ]; then echo $pfx$i; fi\n>  \t\t\tdone\n>  \t\t\tformat=\"refname:short\"\n>  \t\t\trefs=\"refs/tags refs/heads refs/remotes\"\n>  \t\t\t;;\n>  \t\tesac\n> -\t\tgit --git-dir=\"$dir\" for-each-ref --format=\"%($format)\" \\\n> +\t\tgit --git-dir=\"$dir\" for-each-ref --format=\"$pfx%($format)\" \\\n>  \t\t\t$refs\n\nThat looks like a reasonable approach to me (but I am no expert in\nthis area myself).\n\n"}]}