-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PATCH] Guilt: add a new command "files"
The command "files" prints files that are being changed. Currently option -v, -a and -l are supported, but --combine is not. Signed-off-by: Yasushi SHOJI <[email protected]> Signed-off-by: Josef 'Jeff' Sipek <[email protected]>
- Loading branch information
Showing
3 changed files
with
170 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (C) 2007 Yasushi SHOJI <[email protected]> | ||
# | ||
|
||
USAGE="[-v] [-a] [-l]" | ||
. guilt | ||
|
||
opt_verbose= | ||
opt_all= | ||
opt_labels= | ||
|
||
while case "$#" in 0) break ;; esac | ||
do | ||
case "$1" in | ||
-v) | ||
opt_verbose=t ;; | ||
-a) | ||
opt_all=t ;; | ||
-l) | ||
opt_labels=t ;; | ||
*) | ||
usage ;; | ||
esac | ||
shift | ||
done | ||
|
||
IFS=: | ||
if [ $opt_all ]; then | ||
cat $applied | ||
else | ||
tail -1 $applied | ||
fi | while read obj patch; do | ||
# shamelessly taken from Quilt(quilt/quilt/files) | ||
if [ -n "$opt_all" ] && [ -n "$opt_verbose" ] && [ -z "$opt_labels" ]; then | ||
echo "$patch" | ||
fi | ||
if [ -n "$opt_verbose" ] && [ -z "$opt_labels" ]; then | ||
use_status=yes | ||
fi | ||
|
||
IFS=' ' | ||
git diff-tree $obj^ $obj | tr '\t' ' '| | ||
while read omode nmode osha1 nsha1 st file; do | ||
if [ -n "$opt_labels" ]; then | ||
if [ -n "$opt_verbose" ]; then | ||
echo -n "[$patch] " | ||
else | ||
echo -n "$patch " | ||
fi | ||
fi | ||
|
||
if [ -z "$use_status" ]; then | ||
echo "$file" | ||
else | ||
status=" " | ||
if [ $osha1 = "0000000000000000000000000000000000000000" ]; then | ||
status="+" | ||
fi | ||
if [ $nsha1 = "0000000000000000000000000000000000000000" ]; then | ||
status="-" | ||
fi | ||
echo "$status $file" | ||
fi | ||
done | ||
IFS=: | ||
done | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# | ||
# Test the series parsing code | ||
# | ||
|
||
source scaffold | ||
source generic_test_data | ||
|
||
# the test itself | ||
empty_repo | ||
cd $REPODIR | ||
guilt-init | ||
|
||
generic_prepare_for_tests | ||
|
||
function expected_files | ||
{ | ||
echo "def" | ||
} | ||
|
||
function expected_files_label | ||
{ | ||
echo "mode def" | ||
} | ||
|
||
function expected_files_verbose_label | ||
{ | ||
echo "[mode] def" | ||
} | ||
|
||
function expected_files_all | ||
{ | ||
echo "def" | ||
echo "abd" | ||
echo "abd" | ||
echo "def" | ||
} | ||
|
||
function expected_files_label_all | ||
{ | ||
echo "modify def" | ||
echo "add abd" | ||
echo "remove abd" | ||
echo "mode def" | ||
} | ||
|
||
function expected_files_verbose_all | ||
{ | ||
echo "modify" | ||
echo " def" | ||
echo "add" | ||
echo "+ abd" | ||
echo "remove" | ||
echo "- abd" | ||
echo "mode" | ||
echo " def" | ||
} | ||
|
||
function expected_files_verbose_label_all | ||
{ | ||
echo "[modify] def" | ||
echo "[add] abd" | ||
echo "[remove] abd" | ||
echo "[mode] def" | ||
|
||
} | ||
|
||
# push em all for tesing | ||
guilt-push -a > /dev/null | ||
|
||
guilt-files > /tmp/reg.$$ | ||
expected_files | diff -u - /tmp/reg.$$ | ||
echo -n "[files] " | ||
|
||
guilt-files -l > /tmp/reg.$$ | ||
expected_files_label | diff -u - /tmp/reg.$$ | ||
echo -n "[label] " | ||
|
||
guilt-files -v -l > /tmp/reg.$$ | ||
expected_files_verbose_label | diff -u - /tmp/reg.$$ | ||
echo -n "[verbose label] " | ||
|
||
guilt-files -a > /tmp/reg.$$ | ||
expected_files_all | diff -u - /tmp/reg.$$ | ||
echo -n "[all] " | ||
|
||
guilt-files -l -a > /tmp/reg.$$ | ||
expected_files_label_all | diff -u - /tmp/reg.$$ | ||
echo -n "[label all] " | ||
|
||
guilt-files -v -a > /tmp/reg.$$ | ||
expected_files_verbose_all | diff -u - /tmp/reg.$$ | ||
echo -n "[verbose all] " | ||
|
||
guilt-files -v -l -a > /tmp/reg.$$ | ||
expected_files_verbose_label_all | diff -u - /tmp/reg.$$ | ||
echo -n "[verbose label all] " | ||
|
||
rm -f /tmp/reg.$$ | ||
|
||
complete_test | ||
|