zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] __git_commit_objects_prefer_recent: local ret
@ 2015-05-21 17:30 Daniel Hahler
  2015-05-21 18:05 ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Hahler @ 2015-05-21 17:30 UTC (permalink / raw)
  To: zsh-workers

From: Daniel Hahler <git@thequod.de>

Without this, `ret` will be set to 1 with `git diff --ex<tab>` and
result in duplicate entries:

   % git diff --ex<tab>
    -- option --
   --exit-code    -- report exit code 1 if differences, 0 otherwise
   --exit-code  -- report exit code 1 if differences, 0 otherwise
   --ext-diff     -- allow external diff helper to be executed
   --ext-diff   -- allow external diff helper to be executed
   --no-ext-diff  -- disallow external diff helper to be executed
    -- recent commit object name --

I am not sure if this is the right way to do it.
---
 Completion/Unix/Command/_git | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index c886cc9..c9f0b72 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -5605,6 +5605,7 @@ __git_remote_branch_names_noprefix () {
 
 (( $+functions[__git_commit_objects_prefer_recent] )) ||
 __git_commit_objects_prefer_recent () {
+  local ret  # Keep "ret" local here, used in __git_recent_commits.
   __git_recent_commits || __git_commit_objects
 }
 
-- 
2.4.0.dirty


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] __git_commit_objects_prefer_recent: local ret
  2015-05-21 17:30 [PATCH] __git_commit_objects_prefer_recent: local ret Daniel Hahler
@ 2015-05-21 18:05 ` Bart Schaefer
  2015-05-21 18:37   ` Daniel Hahler
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2015-05-21 18:05 UTC (permalink / raw)
  To: zsh-workers

On May 21,  7:30pm, Daniel Hahler wrote:
}
} Without this, `ret` will be set to 1 with `git diff --ex<tab>` and
} result in duplicate entries:
} 
} I am not sure if this is the right way to do it.

Wouldn't it make more sense to put "local ret" in _get_recent_commits ?


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] __git_commit_objects_prefer_recent: local ret
  2015-05-21 18:05 ` Bart Schaefer
@ 2015-05-21 18:37   ` Daniel Hahler
  2015-05-21 21:07     ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Hahler @ 2015-05-21 18:37 UTC (permalink / raw)
  To: Zsh Hackers' List

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 21.05.2015 20:05, Bart Schaefer wrote:
> On May 21,  7:30pm, Daniel Hahler wrote:
> }
> } Without this, `ret` will be set to 1 with `git diff --ex<tab>` and
> } result in duplicate entries:
> } 
> } I am not sure if this is the right way to do it.
> 
> Wouldn't it make more sense to put "local ret" in _get_recent_commits ?
> 

I'm not sure - I've thought it was not used there on purpose, for when it gets called
for --fixup and --squash?

  _arguments -w -S -s \
    '(-a --all --interactive -o --only -i --include *)'{-a,--all}'[stage all modified and deleted paths]' \
    '--fixup=[construct a commit message for use with rebase --autosquash]:commit to be amended:__git_recent_commits' \
    '--squash=[construct a commit message for use with rebase --autosquash]:commit to be amended:__git_recent_commits' \

But putting it there appears to work, too.


Regards,
Daniel.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iD8DBQFVXiXyfAK/hT/mPgARAsOXAKD35BaKCpszaRvmQaOygaMa4Pe3TgCgw+PD
ErPUBrNevfJG+46hYtIfx4k=
=zoKe
-----END PGP SIGNATURE-----


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] __git_commit_objects_prefer_recent: local ret
  2015-05-21 18:37   ` Daniel Hahler
@ 2015-05-21 21:07     ` Bart Schaefer
  2015-05-21 23:04       ` Daniel Hahler
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2015-05-21 21:07 UTC (permalink / raw)
  To: Zsh Hackers' List

On May 21,  8:37pm, Daniel Hahler wrote:
}
} > Wouldn't it make more sense to put "local ret" in _get_recent_commits ?

s/get/git/ (my bad)

} I'm not sure - I've thought it was not used there on purpose, for when
} it gets called for --fixup and --squash?

No, I don't think it is -- "ret" is not declared by _git_commit either,
so the one from _arguments would be getting modified, but that's not part
of the defined interface to _arguments ... it could make _arguments wrong
in the event that _git_recent_commits returns nonzero, in fact.

The right thing is to localize ret and return it (the return statement was
already added by commit 895408bb) both in _git_recent_commits.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] __git_commit_objects_prefer_recent: local ret
  2015-05-21 21:07     ` Bart Schaefer
@ 2015-05-21 23:04       ` Daniel Hahler
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Hahler @ 2015-05-21 23:04 UTC (permalink / raw)
  To: zsh-workers

From: Daniel Hahler <git@thequod.de>

Without this, `ret` will be set to 1 with `git diff --ex<tab>` and
result in duplicate entries:

   % git diff --ex<tab>
    -- option --
   --exit-code    -- report exit code 1 if differences, 0 otherwise
   --exit-code  -- report exit code 1 if differences, 0 otherwise
   --ext-diff     -- allow external diff helper to be executed
   --ext-diff   -- allow external diff helper to be executed
   --no-ext-diff  -- disallow external diff helper to be executed
    -- recent commit object name --

I am not sure if this is the right way to do it.
---
 Completion/Unix/Command/_git | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index c886cc9..4403a48 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -5674,7 +5674,7 @@ __git_commit_objects () {
 __git_recent_commits () {
   local gitdir expl start
   declare -a descr tags heads commits
-  local i j k
+  local i j k ret
   integer distance_from_head
 
   # Careful: most %d will expand to the empty string.  Quote properly!
-- 
2.4.0.dirty


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-05-21 23:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-21 17:30 [PATCH] __git_commit_objects_prefer_recent: local ret Daniel Hahler
2015-05-21 18:05 ` Bart Schaefer
2015-05-21 18:37   ` Daniel Hahler
2015-05-21 21:07     ` Bart Schaefer
2015-05-21 23:04       ` Daniel Hahler

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).