Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Assuming what you mean is:</p> <ul> <li>commit <code>M</code> is a merge commit with two (or more) parents (<code>M^</code> and <code>M^2</code> at least)</li> <li>the complete tree for <code>M</code> is <code>T</code></li> <li>you want to exclude from <code>T</code> any files that were not present in some parent(s)</li> </ul> <p>then one straightforward method to do this is to start with the complete list <code>T</code>, and remove those files. Here's a script that does that, without too much magic in it I think. Lightly tested...</p> <pre><code>#! /bin/sh PROG=$(basename $0) case $# in 1) user_arg="$1";; *) echo "usage: $PROG &lt;commit&gt;" &gt;&amp;2; exit 1;; esac # find full SHA1 of user-specified rev, plus all its parents args=$(git rev-list --no-walk --parents "$user_arg") || exit 1 set -- $args # omit this if you want to just list all files in a non-merge commit case $# in 1|2) echo "$PROG: $user_arg is not a merge commit" &gt;&amp;2; exit 1;; esac # make temp file TF=$(mktemp -t "$PROG") || exit 1 trap "rm -f $TF" 0 1 2 3 15 # save the SHA-1 of the commit, then toss that from arguments c=$1 shift # Now look at each parent: if the file was added between that # parent and commit $c, it was not in that parent, so it's not # "in common" across all parents to the final commit. Dump # such names into a "remove list". # # Remove duplicates from "remove" list. Turn result into series # of regexp's for "grep -v". We need to: # 1) protect any regexp metacharacters: turn . * ^ $ [ \ into # backslash-prefixed versions of same # 2) add ^ at front and $ at end. for parent do git diff-tree -r --name-only --diff-filter=A $parent $c done | sort -u | sed -e 's/[.*^$[\]/\\&amp;/g' -e 's/.*/^&amp;$/' &gt; $TF # Now just run grep -v with that list, with input being the # output of the "master list" of files in commit $c. git ls-tree -r --name-only $c | grep -v -f $TF </code></pre> <p>If you mean something else, the <code>--diff-filter</code> above is tunable.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload