* Additional plumbing commands @ 2015-01-06 16:05 Charles Rudolph 2015-01-06 17:37 ` Christian Couder 0 siblings, 1 reply; 4+ messages in thread From: Charles Rudolph @ 2015-01-06 16:05 UTC (permalink / raw) To: git I am writing some higher level git commands for https://github.com/Originate/git-town and would like some additional plumbing commands that can tell me 1. is there a merge in progress? 2. is there a rebase in progress? 3. is there a cherry-pick in progress? 4. are there unmerged paths? Currently the only way I know how to do this is with "git status" and looking for specific text. Thanks for any and all comments. ~Charlie ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Additional plumbing commands 2015-01-06 16:05 Additional plumbing commands Charles Rudolph @ 2015-01-06 17:37 ` Christian Couder 2015-01-07 8:04 ` Jeff King 0 siblings, 1 reply; 4+ messages in thread From: Christian Couder @ 2015-01-06 17:37 UTC (permalink / raw) To: Charles Rudolph; +Cc: git On Tue, Jan 6, 2015 at 5:05 PM, Charles Rudolph <charles.w.rudolph@gmail.com> wrote: > I am writing some higher level git commands for > https://github.com/Originate/git-town and would like some additional > plumbing commands that can tell me > > 1. is there a merge in progress? > 2. is there a rebase in progress? > 3. is there a cherry-pick in progress? > 4. are there unmerged paths? > > Currently the only way I know how to do this is with "git status" and > looking for specific text. You may have a look at how "contrib/completion/git-prompt.sh" does it. It has stuff like: if [ -d "$g/rebase-merge" ]; then __git_eread "$g/rebase-merge/head-name" b __git_eread "$g/rebase-merge/msgnum" step __git_eread "$g/rebase-merge/end" total if [ -f "$g/rebase-merge/interactive" ]; then r="|REBASE-i" else r="|REBASE-m" fi ... Cheers, Christian. ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Additional plumbing commands 2015-01-06 17:37 ` Christian Couder @ 2015-01-07 8:04 ` Jeff King 2015-01-07 16:31 ` Junio C Hamano 0 siblings, 1 reply; 4+ messages in thread From: Jeff King @ 2015-01-07 8:04 UTC (permalink / raw) To: Christian Couder; +Cc: Charles Rudolph, git On Tue, Jan 06, 2015 at 06:37:34PM +0100, Christian Couder wrote: > On Tue, Jan 6, 2015 at 5:05 PM, Charles Rudolph > <charles.w.rudolph@gmail.com> wrote: > > I am writing some higher level git commands for > > https://github.com/Originate/git-town and would like some additional > > plumbing commands that can tell me > > > > 1. is there a merge in progress? > > 2. is there a rebase in progress? > > 3. is there a cherry-pick in progress? > > 4. are there unmerged paths? > > > > Currently the only way I know how to do this is with "git status" and > > looking for specific text. > > You may have a look at how "contrib/completion/git-prompt.sh" does it. > [...] The prompt code is rather long and knows a lot about the internal state of $GIT_DIR. I do not think it would be a bad thing for git-status to expose a machine-readable version of the state it discovers, and then at least we can keep the logic in one place. Charles, if you are interested in adding that, the wt_status_state code in wt-status.c is the right place to start looking. Though I think in many cases that discovering which state we are in is only half the story that a caller wants. Knowing what each state _means_ and what operations are meaningful to perform is much trickier (e.g., if we are in a rebase, you probably do not want to start a new rebase. But is it wrong to cherry-pick?). It would be nice if we could find a way to generalize in-progress operations and what they mean for starting new operations, but that is a much harder problem (if it is even possible at all). -Peff ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Additional plumbing commands 2015-01-07 8:04 ` Jeff King @ 2015-01-07 16:31 ` Junio C Hamano 0 siblings, 0 replies; 4+ messages in thread From: Junio C Hamano @ 2015-01-07 16:31 UTC (permalink / raw) To: Jeff King; +Cc: Christian Couder, Charles Rudolph, git Jeff King <peff@peff.net> writes: > ... Knowing what each state _means_ > and what operations are meaningful to perform is much trickier (e.g., if > we are in a rebase, you probably do not want to start a new rebase. But > is it wrong to cherry-pick?). > > It would be nice if we could find a way to generalize in-progress > operations and what they mean for starting new operations, but that is > a much harder problem (if it is even possible at all). Very good points. Thinking aloud, to see if we can start from a few rules of thumb. You can be "in the middle" for two largely different reasons. One is that the command inherently wants to give control back to you. Think of a case where you said "exec false" in the "rebase -i" insn sheet, or "bisect" checked out a version for you to try. The other is that the command wanted to continue in the ideal world, but couldn't and stopped asking for your help. Think of a case where "am" stopped due to corrupt patch, "cherry-pick A..B" or "revert" stopped due to conflicts. In the former case, depending on the nature of the command, what are sensible things you can do are very different (during "bisect" you would typically not want to do anything that causes a commit created. During "rebase -i" you may want to run any command that creates a commit, to insert a new one into the series). But a good rule of thumb would be "If I should be able to edit the working tree file, I should also be able to do "cherry-pick --no-commit", "merge --no-commit", "apply", etc." "If I should be able to manually commit, I should also be able to "cherry-pick", "merge", etc. In the latter, the _only_ reason you are given control back is to help the interrupted operation. So "cherry-pick --no-commit" or "apply" in lieu of editing files manually in order to fix conflicts should be allowed, but a random "git merge" (without --no-commit) would not be. So after thinking aloud for a while, I very much agree with you that you cannot say "X is allowed but not Y" in many situations. One thing we can say for sure is that in a middle of a multi-step operation (e.g. rebase, range pick) is stopped for either one of the two reasons, you cannot do another multi-step operation. This is not fundamental but a consequence of how the sequencing machinery is implemented. But other than that, it really is case-by-case and not even command-by-command. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-01-07 16:31 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-01-06 16:05 Additional plumbing commands Charles Rudolph 2015-01-06 17:37 ` Christian Couder 2015-01-07 8:04 ` Jeff King 2015-01-07 16:31 ` Junio C Hamano
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.