1 Return-Path: <wking@tremily.us>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id EE642431FBD
\r
6 for <notmuch@notmuchmail.org>; Sat, 8 Feb 2014 14:22:11 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.1 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id 8qDefOaO-4zx for <notmuch@notmuchmail.org>;
\r
17 Sat, 8 Feb 2014 14:22:04 -0800 (PST)
\r
18 Received: from qmta06.westchester.pa.mail.comcast.net
\r
19 (qmta06.westchester.pa.mail.comcast.net [76.96.62.56])
\r
20 by olra.theworths.org (Postfix) with ESMTP id 9E88A431FBC
\r
21 for <notmuch@notmuchmail.org>; Sat, 8 Feb 2014 14:22:04 -0800 (PST)
\r
22 Received: from omta10.westchester.pa.mail.comcast.net ([76.96.62.28])
\r
23 by qmta06.westchester.pa.mail.comcast.net with comcast
\r
24 id PyKz1n0050cZkys56yN4fV; Sat, 08 Feb 2014 22:22:04 +0000
\r
25 Received: from odin.tremily.us ([24.18.63.50])
\r
26 by omta10.westchester.pa.mail.comcast.net with comcast
\r
27 id PyN21n011152l3L3WyN3qs; Sat, 08 Feb 2014 22:22:04 +0000
\r
28 Received: by odin.tremily.us (Postfix, from userid 1000)
\r
29 id 9B1B9100CE27; Sat, 8 Feb 2014 14:22:02 -0800 (PST)
\r
30 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tremily.us; s=odin;
\r
31 t=1391898122; bh=o75bWkeWM0p2RXTBJ3lBe0hiw5/97kKcUod/5gi1uD8=;
\r
32 h=From:To:Cc:Subject:Date;
\r
33 b=KRXpRjE4Mv9/mJpgRox6+mlXco3JJiXrqqpsHzliMDmB7vneLeY4BwVbKznDTU8ty
\r
34 9YnZAOGwIwXEr7WF5NXL7I9Vq1UAMoWV2nkXqiiT4sErFi9BHxp8Clr8lWrAPtxJ1p
\r
35 zTVIdOBHdCi+mMbsvK84Kbj4+R7buwgSil6O0VE4=
\r
36 From: "W. Trevor King" <wking@tremily.us>
\r
37 To: notmuch@notmuchmail.org
\r
38 Subject: [PATCH] nmbug: Add 'clone' and replace FETCH_HEAD with @{upstream}
\r
39 Date: Sat, 8 Feb 2014 14:21:56 -0800
\r
41 <80db13662a0313711ca3a91e338a63d35e64a83c.1391898002.git.wking@tremily.us>
\r
42 X-Mailer: git-send-email 1.8.3.2
\r
44 Content-Type: text/plain; charset=UTF-8
\r
45 Content-Transfer-Encoding: 8bit
\r
46 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net;
\r
47 s=q20121106; t=1391898124;
\r
48 bh=bmBTU1oJm+L9LEh/+EQcR5h/juBlcwMTDf00HAHRAno=;
\r
49 h=Received:Received:Received:From:To:Subject:Date:Message-Id:
\r
50 MIME-Version:Content-Type;
\r
51 b=MJ458FFdKX88XxPL/2j3r2/GBNZRYbeIFZiX0HonsxyFnPxxeOCM4SMmW1gCYQu3E
\r
52 H7Wjm9kgJEXerpWXhVRk6iJ4YbxYYPW23n8lt8edTUuEHuXS1ibHm98gb3PjWhKsNo
\r
53 TYumjEjbmlG2wSwxKp1QErDbuVTkoke9zJ4pUQtonlK+MOaEyiR3l7XUW3l62SuH1Q
\r
54 42H0O0uIGRw24jpRLpttGx2CUQIf6fqhZspCfE8khPDuD0pr78cGx/jIOeBg8JRcj9
\r
55 /jHAZ7vHHSUJ5vnWbYrMAdNX9CrO+5pIK0B5OKUTEhT+ohTIdv0aAJ5Nwx1HHqICJG
\r
57 X-BeenThere: notmuch@notmuchmail.org
\r
58 X-Mailman-Version: 2.1.13
\r
60 List-Id: "Use and development of the notmuch mail system."
\r
61 <notmuch.notmuchmail.org>
\r
62 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
63 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
64 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
65 List-Post: <mailto:notmuch@notmuchmail.org>
\r
66 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
67 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
68 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
69 X-List-Received-Date: Sat, 08 Feb 2014 22:22:12 -0000
\r
71 From: "W. Trevor King" <wking@tremily.us>
\r
73 With two branches getting fetched (master and config), the branch
\r
74 referenced by FETCH_HEAD is ambiguous. For example, I have:
\r
77 41d7bfa7184cc93c9dac139d1674e9530799e3b0 \
\r
78 not-for-merge branch 'config' of http://nmbug.tethera.net/git/nmbug-tags
\r
79 acd379ccb973c45713eee9db177efc530f921954 \
\r
80 not-for-merge branch 'master' of http://nmbug.tethera.net/git/nmbug-tags
\r
82 (where I wrapped the line by hand). This means that FETCH_HEAD
\r
83 references the config branch:
\r
85 $ git rev-parse FETCH_HEAD
\r
86 41d7bfa7184cc93c9dac139d1674e9530799e3b0
\r
88 which breaks all of the FETCH_HEAD logic in nmbug (where FETCH_HEAD is
\r
89 assumed to point to the master branch).
\r
91 Instead of relying on FETCH_HEAD, use @{upstream} as the
\r
92 remote-tracking branch that should be merged/diffed/integrated into
\r
93 HEAD. @{upstream} was added in Git v1.7.0 (2010-02-12) [1], so
\r
94 relying on it should be fairly safe. One tricky bit is that bare
\r
95 repositories don't set upstream tracking branches by default:
\r
97 $ git clone --bare http://nmbug.tethera.net/git/nmbug-tags.git nmbug-bare
\r
99 $ git remote show origin
\r
101 Fetch URL: http://nmbug.tethera.net/git/nmbug-tags.git
\r
102 Push URL: http://nmbug.tethera.net/git/nmbug-tags.git
\r
103 HEAD branch: master
\r
104 Local refs configured for 'git push':
\r
105 config pushes to config (up to date)
\r
106 master pushes to master (up to date)
\r
108 While in a non-bare clone:
\r
110 $ git clone http://nmbug.tethera.net/git/nmbug-tags.git
\r
112 $ git remote show origin
\r
114 Fetch URL: http://nmbug.tethera.net/git/nmbug-tags.git
\r
115 Push URL: http://nmbug.tethera.net/git/nmbug-tags.git
\r
116 HEAD branch: master
\r
120 Local branch configured for 'git pull':
\r
121 master merges with remote master
\r
122 Local ref configured for 'git push':
\r
123 master pushes to master (up to date)
\r
125 >From the clone docs [2]:
\r
128 Make a 'bare' Git repository…
\r
129 Also the branch heads at the remote are copied directly
\r
130 to corresponding local branch heads, without mapping
\r
131 them to `refs/remotes/origin/`. When this option is
\r
132 used, neither remote-tracking branches nor the related
\r
133 configuration variables are created.
\r
135 To use @{upstream}, we need to restore the local vs. remote-tracking
\r
136 distinction, so this commit adds 'nmbug clone', which adds the
\r
137 following configuration adjustments:
\r
139 $ git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'
\r
140 $ git config branch.$branch.remote origin
\r
141 $ git config branch.$branch.merge refs/heads/$branch
\r
143 where $branch is the branch referenced by the remote's HEAD, which
\r
144 'git clone' uses to setup the local branch. After tweaking the
\r
145 config, we populate the new remote-tracking branches with:
\r
151 $ git rev-parse @{upstream}
\r
152 acd379ccb973c45713eee9db177efc530f921954
\r
154 gives us the master-branch commit. Existing nmbug users will have to
\r
155 run the configuration tweaks and re-fetch by hand. If you don't have
\r
156 any local commits, you could also blow away your NMBGIT repository and
\r
157 re-clone from scratch:
\r
159 $ nmbug clone http://nmbug.tethera.net/git/nmbug-tags.git
\r
161 Besides removing the ambiguity of FETCH_HEAD, this commit allows users
\r
162 to configure which upstream branch they want nmbug to track via 'git
\r
163 config', in case they want to change their upstream repository.
\r
165 [1]: http://git.kernel.org/cgit/git/git.git/tree/Documentation/RelNotes/1.7.0.txt
\r
166 [2]: http://git.kernel.org/cgit/git/git.git/tree/Documentation/git-clone.txt
\r
168 devel/nmbug/nmbug | 49 +++++++++++++++++++++++++++++++++++--------------
\r
169 1 file changed, 35 insertions(+), 14 deletions(-)
\r
171 diff --git a/devel/nmbug/nmbug b/devel/nmbug/nmbug
\r
172 index 90d98b6..3c1d597 100755
\r
173 --- a/devel/nmbug/nmbug
\r
174 +++ b/devel/nmbug/nmbug
\r
175 @@ -26,6 +26,7 @@ my $ESCAPED_RX = qr{$ESCAPE_CHAR([A-Fa-f0-9]{2})};
\r
177 archive => \&do_archive,
\r
178 checkout => \&do_checkout,
\r
179 + clone => \&do_clone,
\r
180 commit => \&do_commit,
\r
181 fetch => \&do_fetch,
\r
183 @@ -125,6 +126,17 @@ sub do_archive {
\r
184 system ('git', "--git-dir=$NMBGIT", 'archive', 'HEAD');
\r
188 + my $repository = shift;
\r
189 + system ('git', 'clone', '--bare', $repository, $NMBGIT) == 0
\r
190 + or die "'git clone' exited with nonzero value\n";
\r
191 + my $branch = git ('symbolic-ref', 'HEAD');
\r
192 + $branch =~ s|^refs/heads/||;
\r
193 + git ('config', 'remote.origin.fetch', '+refs/heads/*:refs/remotes/origin/*');
\r
194 + git ('config', "branch.$branch.remote", 'origin');
\r
195 + git ('config', "branch.$branch.merge", 'refs/heads/$branch');
\r
200 my $status = shift;
\r
201 @@ -332,21 +344,24 @@ To discard your changes, run 'nmbug checkout'
\r
204 my $remote = shift || 'origin';
\r
205 + my $branch = shift || 'master';
\r
207 git ( 'fetch', $remote);
\r
210 + do_merge ("$remote/$branch");
\r
215 + my $commit = shift || '@{upstream}';
\r
217 insist_committed ();
\r
219 my $tempwork = tempdir ('/tmp/nmbug-merge.XXXXXX', CLEANUP => 1);
\r
221 git ( { GIT_WORK_TREE => $tempwork }, 'checkout', '-f', 'HEAD');
\r
223 - git ( { GIT_WORK_TREE => $tempwork }, 'merge', 'FETCH_HEAD');
\r
224 + git ( { GIT_WORK_TREE => $tempwork }, 'merge', $commit);
\r
228 @@ -407,13 +422,12 @@ sub do_status {
\r
232 + my $commit = shift || '@{upstream}';
\r
234 - return 0 if (! -f $NMBGIT.'/FETCH_HEAD');
\r
236 - my $fetch_head = git ('rev-parse', 'FETCH_HEAD');
\r
237 - my $base = git ( 'merge-base', 'HEAD', 'FETCH_HEAD');
\r
238 + my $upstream = git ('rev-parse', $commit);
\r
239 + my $base = git ( 'merge-base', 'HEAD', $commit);
\r
241 - return ($base ne $fetch_head);
\r
242 + return ($base ne $upstream);
\r
246 @@ -473,7 +487,7 @@ sub diff_index {
\r
248 my $filter = shift;
\r
249 my $ref1 = shift || 'HEAD';
\r
250 - my $ref2 = shift || 'FETCH_HEAD';
\r
251 + my $ref2 = shift || '@{upstream}';
\r
253 my $fh= git_pipe ( 'diff', "--diff-filter=$filter", '--name-only',
\r
255 @@ -561,10 +575,11 @@ git. Any extra arguments are used (one per line) as a commit message.
\r
257 push local nmbug git state to remote repo
\r
259 -=item B<pull> [remote]
\r
260 +=item B<pull> [remote] [branch]
\r
262 pull (merge) remote repo changes to notmuch. B<pull> is equivalent to
\r
263 -B<fetch> followed by B<merge>.
\r
264 +B<fetch> followed by B<merge>. The default remote is C<origin>, and
\r
265 +the default branch is C<master>.
\r
269 @@ -572,6 +587,12 @@ B<fetch> followed by B<merge>.
\r
273 +=item B<clone> repository
\r
275 +Create a local nmbug repository from a remote source. This wraps
\r
276 +C<git clone --bare>, adding some configuration adjustments to setup
\r
277 +remote-tracking branches and upstreams.
\r
281 Update the notmuch database from git. This is mainly useful to discard
\r
282 @@ -589,12 +610,12 @@ print help [for subcommand]
\r
283 =item B<log> [parameters]
\r
285 A simple wrapper for git log. After running C<nmbug fetch>, you can
\r
286 -inspect the changes with C<nmbug log HEAD..FETCH_HEAD>
\r
287 +inspect the changes with C<nmbug log HEAD..@{upstream}>
\r
290 +=item B<merge> [commit]
\r
292 -Merge changes from FETCH_HEAD into HEAD, and load the result into
\r
294 +Merge changes from C<commit> into HEAD, and load the result into
\r
295 +notmuch. The default commit is C<@{upstream}>.
\r