Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7929551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:07:28+00:00 2026-06-03T20:07:28+00:00

I set *.py diff=python in .git/info/attributes . So Git knows where function boundaries. git

  • 0

I set *.py diff=python in .git/info/attributes. So Git knows where function boundaries. git diff -W can even make sure the whole function is shown.

But is there a way to limit the output of a git diff to just a particular function (or more than one)?

(Failing that, I guess it’s awk…)

EDIT This would also be useful for git log and git rev-list: don’t show me every commit that modifies views.py, show me commits that modify a certain function in it. (Yes, in an ideal world, views.py wouldn’t be a 2000 line behemoth frequently modified by 8 different developers…)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T20:07:30+00:00Added an answer on June 3, 2026 at 8:07 pm

    Ok, thanks to Birei, we have a solution.

    Use the awk script in that answer, combined with a bit of bash:

    ~/scripts/grit:

    #!/bin/bash
    cmd=$1
    shift 1
    if [ "$cmd" = "" ]; then
      git
    # other commands not relevant to this question go here
    elif [ $cmd = "funcdiff" ]; then
      git show "$1:$3" | awk -f ~/scripts/getfunc.awk -v f=$4 > /tmp/.tmp1
      git show "$2:$3" | awk -f ~/scripts/getfunc.awk -v f=$4 > /tmp/.tmp2
      git diff -W --no-index /tmp/.tmp1 /tmp/.tmp2 
    
    else
      git $cmd $@
    fi
    

    Example usage: grit funcdiff 009e75 8b7a14 ./staging.py write_uploaded

    This could also be added as a git alias in ~/.gitconfig

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there an option to restrict git diff to a given set of file
Is there a utility that can do a diff between a set of files
Is it possible to set Git up so that I can use the three-way
After a merge failed with some conflicts, I can list those with git diff
I finally set up a git and review board server. I am sure Git
1 set: $('#tabs li:first-child').addClass('first-child'); $('.photos li:first-child').addClass('first-child'); $('#alphabet li:first-child').addClass('first-child'); 2 set: $(function(){ $(#header-thumbs img).fadeTo(fast,1); $(#header-thumbs
how to change listbox to set background color of alternate row diff... e.g. Listbox
I have succeeded in getting git to start Beyond Compare 3 as a diff
UPDATE: An idea to make built-in strings non-iterable was proposed on python.org in 2006
In Xcode, I want to set the project bundle version to the git hash,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.