Skip to content

Commit

Permalink
[PATCH] Guilt: add a new command "files"
Browse files Browse the repository at this point in the history
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
yashi authored and Josef 'Jeff' Sipek committed Mar 1, 2007
1 parent 3ea2c09 commit 21cbd49
Show file tree
Hide file tree
Showing 3 changed files with 170 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ SCRIPTS = guilt \
guilt-add \
guilt-applied \
guilt-delete \
guilt-files \
guilt-header \
guilt-import-commit \
guilt-init \
Expand Down
68 changes: 68 additions & 0 deletions guilt-files
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

101 changes: 101 additions & 0 deletions regression/060-files.sh
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

0 comments on commit 21cbd49

Please sign in to comment.