The officially official Devuan Forum!

You are not logged in.

#1 2024-10-02 16:39:51

zapper
Member
Registered: 2017-05-29
Posts: 969  

How to replace all mentions in git soure code,

I am basically asking, something in continuation to this:

http://dev1galaxy.org/viewtopic.php?id=6857

How can I replace all mentions instead of a word instead of searching for it.

Through all of a git folders/repo

Last edited by zapper (2024-10-02 16:40:06)


Freedom is never more than one generation away from extinction. Feelings are not facts
If you wish to be humbled, try to exalt yourself long term  If you wish to be exalted, try to humble yourself long term
Favourite operating systems: Hyperbola Devuan OpenBSD
Peace Be With us All!

Offline

#2 2024-10-02 17:19:59

fsmithred
Administrator
Registered: 2016-11-25
Posts: 2,495  

Re: How to replace all mentions in git soure code,

From the root of the git repo:

find . -type f -exec sed -i 's/old-word/new-word/g' {} \;

Be careful with your words! (e.g. don't change a word that might be part of a word that's not the intended word.)

Offline

#3 2024-10-02 18:08:18

golinux
Administrator
Registered: 2016-11-25
Posts: 3,336  

Re: How to replace all mentions in git soure code,

You are giving zapper a loaded gun to play with?! Oh my!!!  big_smile

Offline

#4 2024-10-02 19:24:28

zapper
Member
Registered: 2017-05-29
Posts: 969  

Re: How to replace all mentions in git soure code,

@golinux which is why I am replacing python2.7 with tauthon instead of python with tauthon

;P

Btw, I used this command after doing that:

git rev-list --all | xargs git grep -F python2.7

and it still shows python2.7 mentions... weird stuff.

Correcting what I said, I wrote down the wrong one.

Last edited by zapper (2024-10-02 20:34:29)


Freedom is never more than one generation away from extinction. Feelings are not facts
If you wish to be humbled, try to exalt yourself long term  If you wish to be exalted, try to humble yourself long term
Favourite operating systems: Hyperbola Devuan OpenBSD
Peace Be With us All!

Offline

#5 2024-10-02 20:10:01

fsmithred
Administrator
Registered: 2016-11-25
Posts: 2,495  

Re: How to replace all mentions in git soure code,

You said, "I used this command after doing that."

I ask, "What did you do before you ran that 'find' command?"  It should have worked.

Offline

#6 2024-10-02 20:33:23

zapper
Member
Registered: 2017-05-29
Posts: 969  

Re: How to replace all mentions in git soure code,

In simple terms, I did this:

find . -type f -exec sed -i 's/old-word/new-word/g' {} \;

Then I did my command to check to see if it was fixed,

git rev-list --all | xargs git grep -F python2.7

I seem to have gotten mixed up and written wrong thing down... my bad.

In any case, that might help clear up the confusion.

Does the find command you gave me actually replace all mentions of the word python2.7 if I put it as first word with the second word in all source code?

Or am I really confused.

Last edited by zapper (2024-10-02 20:33:33)


Freedom is never more than one generation away from extinction. Feelings are not facts
If you wish to be humbled, try to exalt yourself long term  If you wish to be exalted, try to humble yourself long term
Favourite operating systems: Hyperbola Devuan OpenBSD
Peace Be With us All!

Offline

#7 2024-10-02 21:33:01

ralph.ronnquist
Administrator
From: Battery Point, Tasmania, AUS
Registered: 2016-11-30
Posts: 1,262  

Re: How to replace all mentions in git soure code,

Yes you are confused smile.

That find command of @fsmithred, when taken literally, will replace all occurrences of "old-word" (literally) with "new-word" (literally), and it will do nothing to occurrences of "python2.7".

That is a puzzle for ome and not for others.

Offline

#8 2024-10-02 23:12:11

fsmithred
Administrator
Registered: 2016-11-25
Posts: 2,495  

Re: How to replace all mentions in git soure code,

Yeah, you have to tell sed exactly what to find and replace.

find . -type f -exec sed -i 's/python2.7/tauthon/g' {} \;

Offline

#9 2024-10-03 05:08:24

zapper
Member
Registered: 2017-05-29
Posts: 969  

Re: How to replace all mentions in git soure code,

@fsmithred hmm... weird I tried that and it still left stuff behind unchanged...


Freedom is never more than one generation away from extinction. Feelings are not facts
If you wish to be humbled, try to exalt yourself long term  If you wish to be exalted, try to humble yourself long term
Favourite operating systems: Hyperbola Devuan OpenBSD
Peace Be With us All!

Offline

#10 2024-10-03 07:07:50

ralph.ronnquist
Administrator
From: Battery Point, Tasmania, AUS
Registered: 2016-11-30
Posts: 1,262  

Re: How to replace all mentions in git soure code,

The command you are using,

git rev-list --all | xargs git grep -F python2.7

scans all versions of all files in reverse chronological order, to find "python2.7".

Probably you mean to only check the latest version of the files? Like

grep  -F python2.7 -r *

which would not report any match.

Offline

#11 2024-10-03 07:44:27

zapper
Member
Registered: 2017-05-29
Posts: 969  

Re: How to replace all mentions in git soure code,

@ralph.ronnquist fair point hmm....

Yeah, it must keep resetting... then.  I am doing something a bit out of the norm anyhow for here.

So I will leave it at that.

Last edited by zapper (2024-10-03 07:47:10)


Freedom is never more than one generation away from extinction. Feelings are not facts
If you wish to be humbled, try to exalt yourself long term  If you wish to be exalted, try to humble yourself long term
Favourite operating systems: Hyperbola Devuan OpenBSD
Peace Be With us All!

Offline

Board footer