git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] allow git-am to run in a subdirectory
@ 2008-03-01  6:22 Jeff King
  2008-03-01  7:38 ` Junio C Hamano
  0 siblings, 1 reply; 11+ messages in thread
From: Jeff King @ 2008-03-01  6:22 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

We just move to the top of the tree and proceed. This
shouldn't break any existing callers, since the behavior was
previously disallowed.

Signed-off-by: Jeff King <peff@peff.net>
---
I can't imagine anyone would be confused by this behavior. The only
other behavior that would make sense is perhaps trying to apply from the
given prefix rather than moving to the toplevel, but that just seems
crazy and useless to me.

It will fail to find your mbox file if you specified a relative path
and it had to change directories. I don't know if that case is worth
handling.

My use case, btw, is that I have an "apply this patch" macro in my MUA.
For some messages, it's easy to guess "cd /my/git/repo && git am". But
for others, the repo is not obvious, so I apply in the current
directory. If I am at the root of the repo, it works fine. If I'm not,
then it fails annoyingly.

 git-am.sh |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/git-am.sh b/git-am.sh
index 2ecebc4..a2c6fea 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -2,6 +2,7 @@
 #
 # Copyright (c) 2005, 2006 Junio C Hamano
 
+SUBDIRECTORY_OK=Yes
 OPTIONS_KEEPDASHDASH=
 OPTIONS_SPEC="\
 git-am [options] <mbox>|<Maildir>...
@@ -25,6 +26,7 @@ skip            skip the current patch"
 . git-sh-setup
 set_reflog_action am
 require_work_tree
+cd_to_toplevel
 
 git var GIT_COMMITTER_IDENT >/dev/null || exit
 
-- 
1.5.4.3.422.g55194

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

end of thread, other threads:[~2008-03-03 17:02 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-01  6:22 [PATCH] allow git-am to run in a subdirectory Jeff King
2008-03-01  7:38 ` Junio C Hamano
2008-03-01  8:12   ` Jeff King
2008-03-01  8:15     ` Junio C Hamano
2008-03-01  8:20       ` Jeff King
2008-03-03  3:26     ` Jay Soffian
2008-03-03  6:46     ` Re* " Junio C Hamano
2008-03-03  6:58       ` Jeff King
2008-03-03  7:08         ` Junio C Hamano
2008-03-03 11:53           ` Johannes Schindelin
2008-03-03 17:01             ` Junio C Hamano

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).