Commit | Line | Data |
---|---|---|
22584709 YD |
1 | #!/bin/sh |
2 | set -e | |
3 | ||
4 | # stg-k - execute given StGIT command while preserving local changes | |
5 | ||
6 | # Uses a temporary patch to save local changes, then execute the given | |
7 | # command, and restore local changes from the saved patch. In | |
8 | # essence, "stg-k pop" is a "stg pop -k" that works better, hence its | |
9 | # name. | |
10 | ||
0214be72 YD |
11 | # CAVEATS: |
12 | # - this script relies on the operation to run ignoring hidden | |
22584709 YD |
13 | # patches, so in 0.12 (where "stg push" can push an hidden patch) |
14 | # "stg-k push" will fail midway, albeit with no information loss - | |
0214be72 YD |
15 | # you'll just have to finish manually. This is fixed in 0.13 |
16 | # - running this script to pop all patches in the stack fails, since | |
17 | # stg-unnew does not support this case. | |
22584709 YD |
18 | |
19 | # Copyright (c) 2007 Yann Dirson <ydirson@altern.org> | |
20 | # Subject to the GNU GPL, version 2. | |
21 | ||
22 | stg new __local -m " - local changes (internal patch)" | |
23 | stg refresh | |
24 | stg pop | |
25 | ||
26 | # avoid bad interactions like "stg-k push" not behaving as expected | |
27 | stg hide __local | |
28 | ||
29 | stg "$@" | |
30 | ||
31 | stg unhide __local | |
32 | ||
33 | stg push __local | |
34 | stg-unnew |