git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michel Marti <mma@objectxp.com>
To: git@vger.kernel.org
Subject: Re: Feature request: Limit git-status reports to a directory
Date: Thu, 25 Oct 2007 15:03:35 +0200	[thread overview]
Message-ID: <ffq477$mji$1@ger.gmane.org> (raw)
In-Reply-To: <Pine.LNX.4.64.0710251050390.25221@racer.site>

[-- Attachment #1: Type: text/plain, Size: 755 bytes --]

on 10/25/2007 11:55 AM Johannes Schindelin said the following:
> I am not so sure.  In other SCMs, "git status" may be a way to do "git 
> diff --name-only" or "git ls-files", but not in git.  Here, it strictly 
> means "what would be happening if I were to commit _right_ _now_?".
I somehow agree with your argument, but then again, sometimes I'm still interested in
*only* the status for a given directory.

IMHO, answering the question "what would be happening if...?" should be  git-commit's task
(e.g. git-commit --dry-run). And git-status should behave similar to git-log and git-diff.

For those interested: I have attached a little script that mimics current git-status
(except the "dry-run" stuff) but also can take a list of directories/files.


[-- Attachment #2: git-status-new --]
[-- Type: text/plain, Size: 1957 bytes --]

#!/bin/sh

USAGE='[--staged] [--changed] [--untracked]'
SUBDIRECTORY_OK=1 . git-sh-setup
require_work_tree

print_stat_line() {
	case "$1" in
		M)	echo "#       modified:  $2";;
		A)	echo "#       new file:  $2";;
		R*)	echo "#       renamed:   $2 -> $3";;
		D)	echo "#       deleted:   $2";;
		U)	echo "#       unmerged:  $2";;
		X)	echo "#       $2";;
		*)	echo "#       [$S]:      $2";;
	esac
}

STAGED= CHANGED= UNTRACKED= HP=

while test $# != 0
do
	case "$1" in
		-s|--staged) STAGED=1; shift;;
		-c|--changed) CHANGED=1; shift;;
		-u|--untracked) UNTRACKED=1; shift;;
		--) shift; break;;
		-*) usage;;
		 *) break;;
	esac
done

if BRANCH_NAME=$(git symbolic-ref -q HEAD)
then
	BRANCH_NAME="On branch $(expr "z$BRANCH_NAME" : 'zrefs/heads/\(.*\)')"
else
	BRANCH_NAME="Not currently on any branch"
fi

[ "$#" = 0 ] && cd_to_toplevel


if [ -z "$STAGED$CHANGED$UNTRACKED" ]; then
	STAGED=1; CHANGED=1; UNTRACKED=1
fi

SP=$(echo _/$(git rev-parse --show-cdup)|tr '/' ' '|wc -w)

echo "# $BRANCH_NAME"

# Changes to be commited
[ "$STAGED" ] && git-diff --name-status --cached -M -- "$@"|while read S F R
do
	if [ -z "$HP" ]; then
		echo '# Changes to be committed:'
		echo '#   (use "git reset HEAD <file>..." to unstage)'
		echo '#'
		HP=1
	fi
	F=$(echo $F|cut -d'/' -f$SP-)
	print_stat_line "$S" "$F" "$R"

done

# Changed but not updated
[ "$CHANGED" ] && git-diff --name-status -- "$@"|while read S F
do
	if [ -z "$HP" ]; then
		echo '#'
		echo '# Changed but not updated:'
		echo '#   (use "git add <file>..." to update what will be committed)'
		echo '#'
		HP=1
	fi
	F=$(echo $F|cut -d'/' -f$SP-)
	print_stat_line "$S" "$F"
done

# Untracked files
[ "$UNTRACKED" ] && git-ls-files --exclude-per-directory=.gitignore -o --directory -- "$@"|while read F
do
	if [ -z "$HP" ]; then
		echo '#'
		echo '# Untracked files:'
		echo '#   (use "git add <file>..." to include in what will be committed)'
		echo '#'
		HP=1
	fi
	print_stat_line "X" "$F"
done


      parent reply	other threads:[~2007-10-25 13:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-24 22:01 Feature request: Limit git-status reports to a directory Michel Marti
2007-10-25  2:14 ` Yin Ping
2007-10-25  9:55   ` Johannes Schindelin
2007-10-25 13:03     ` Wincent Colaiuta
2007-10-25 13:03     ` Michel Marti [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='ffq477$mji$1@ger.gmane.org' \
    --to=mma@objectxp.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).