diff options
author | Junio C Hamano <gitster@pobox.com> | 2012-09-12 15:56:53 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-09-12 15:56:53 -0700 |
commit | 693e70961ac5a79a46303795f3ca6a0bfd62f375 (patch) | |
tree | 70fc25a554a7d96d42e8d233d57316d63f603c47 /git-merge-base.html | |
parent | eccdd4a4b39010678cef09a1c28c964396d2cc84 (diff) | |
download | git-htmldocs-693e70961ac5a79a46303795f3ca6a0bfd62f375.tar.gz |
Autogenerated HTML docs for v1.7.12-395-g6b149
Diffstat (limited to 'git-merge-base.html')
-rw-r--r-- | git-merge-base.html | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/git-merge-base.html b/git-merge-base.html index 23eaadfdb..91a4557be 100644 --- a/git-merge-base.html +++ b/git-merge-base.html @@ -585,6 +585,7 @@ git-merge-base(1) Manual Page <div class="verseblock">
<div class="verseblock-content"><em>git merge-base</em> [-a|--all] <commit> <commit>…
<em>git merge-base</em> [-a|--all] --octopus <commit>…
+<em>git merge-base</em> --is-ancestor <commit> <commit>
<em>git merge-base</em> --independent <commit>…</div>
<div class="verseblock-attribution">
</div></div>
@@ -632,6 +633,16 @@ from <a href="git-show-branch.html">git-show-branch(1)</a> when used with the <t --independent</em>.
</p>
</dd>
+<dt class="hdlist1">
+--is-ancestor
+</dt>
+<dd>
+<p>
+ Check if the first <commit> is an ancestor of the second <commit>,
+ and exit with status 0 if true, or with status 1 if not.
+ Errors are signaled by a non-zero status that is not 1.
+</p>
+</dd>
</dl></div>
</div>
<h2 id="_options">OPTIONS</h2>
@@ -701,6 +712,27 @@ the best common ancestor of all commits.</p></div> <div class="paragraph"><p>both <em>1</em> and <em>2</em> are merge-bases of A and B. Neither one is better than
the other (both are <em>best</em> merge bases). When the <tt>--all</tt> option is not given,
it is unspecified which best one is output.</p></div>
+<div class="paragraph"><p>A common idiom to check "fast-forward-ness" between two commits A
+and B is (or at least used to be) to compute the merge base between
+A and B, and check if it is the same as A, in which case, A is an
+ancestor of B. You will see this idiom used often in older scripts.</p></div>
+<div class="literalblock">
+<div class="content">
+<pre><tt>A=$(git rev-parse --verify A)
+if test "$A" = "$(git merge-base A B)"
+then
+ ... A is an ancestor of B ...
+fi</tt></pre>
+</div></div>
+<div class="paragraph"><p>In modern git, you can say this in a more direct way:</p></div>
+<div class="literalblock">
+<div class="content">
+<pre><tt>if git merge-base --is-ancestor A B
+then
+ ... A is an ancestor of B ...
+fi</tt></pre>
+</div></div>
+<div class="paragraph"><p>instead.</p></div>
</div>
<h2 id="_see_also">See also</h2>
<div class="sectionbody">
@@ -716,7 +748,7 @@ it is unspecified which best one is output.</p></div> <div id="footnotes"><hr /></div>
<div id="footer">
<div id="footer-text">
-Last updated 2011-11-15 13:45:02 PDT
+Last updated 2012-09-12 15:56:23 PDT
</div>
</div>
</body>
|