Created
March 23, 2019 14:51
-
-
Save tai/8057bcae42907aeaabc52bb2824870d7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| usage() { | |
| local p=$(basename $0) | |
| cat <<EOF >&2 | |
| $p - List changed file that may be in other version tree | |
| Usage: $p <tag> | |
| Example: | |
| // current state is based on v2.6.32 | |
| $ git log -1 --oneline | |
| 22763c5cf369 (HEAD -> dsm232-port, tag: v2.6.32) Linux 2.6.32 | |
| // list changed files that seems to be in v2.6.32.45 | |
| $ $p v2.6.32.45 | head -3 | |
| Documentation/Changes | |
| Documentation/DocBook/Makefile | |
| Documentation/filesystems/ext4.txt | |
| // revert matching files to state as of v2.6.32 | |
| $ $p v2.6.32.45 | xargs -n1 git checkout -f v2.6.32 -- | |
| // remove those failed to revert back (= nonexistent as of v2.6.32) | |
| $ $p v2.6.32.45 | xargs rm | |
| // same as above, but more efficient | |
| $ $p v2.6.32.45 | \\ | |
| xargs -n1 -I{} sh -c "git checkout -f v2.6.32 -- '{}' || rm '{}'" | |
| EOF | |
| exit 1 | |
| } | |
| run() { | |
| local tag=$1 | |
| # on Linux, bash allocates fd#63, 62, ... for in-place pipes created | |
| textql -sql "SELECT * FROM '63' EXCEPT SELECT * FROM '62'" \ | |
| <(git ls-files -om) \ | |
| <(git diff --name-only $tag) \ | |
| | xargs git ls-files --with-tree=$tag -- | |
| } | |
| test $# -gt 0 || usage | |
| run "$@" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment